I am working on allowing a user to enter an ID # using JOptionPane. If the ID is valid, then it will display the ID#, student name, and GPA. If it is not valid, then the window should pop up again to allow the user to enter a valid ID. I have managed to get that far.
I am struggling with once a valid ID # is entered, how do I get the loop to stop? I have tried several different ways, but the code below is the most recent one, and it is still not working!
import javax.swing.*;
public class StudentIDArray
{
public static void main(String[] args)
{
String enteredID;
int idNumber;
int x = 0;
import java.io.*; public class pho { public static void main (String args[]) throws IOException { BufferedReader br = new BufferedReader (new InputStreamReader (System.in)); String name = new String [50]; long phn = new long [50]; System.out.println("enter A for adding phone numbers");
how many integers the user wants to use. The user will enter for example a 4. The user inputs a 2, 4, 6, and 10. So then we get our outputs...Then the code will ask if you want to run this program again. My question is, if the user inputs a -1 for example 2, 4, 6, -1....the code will not continue. I wanted to use a while loop, such as while (scores != -1) but it doesn't work.
Enter the amount of integers you want to use4 Intenger # 1 2 Intenger # 2 4 Intenger # 3 6 Intenger # 4 10 You entered 2.0 4.0 6.0 10.0 Average = 5.5 Variance = 8.75 Standard Deviation = 2.96 Do you have another set of numbers?
i am writing a program that would be used for ticket sales and their are 100 tickets and a person can only buy 4 at a time. i need my program to not go negative at the end and also i need to stop the user from entering a negative number.
import java.util.Scanner; public class ticketmaster { public static void main(String[] args) { // Variable decoration uses strings , doubles and final doubles. Scanner in = new Scanner(System.in);
i am writing a program that would be used for ticket sales and their are 100 tickets and a person can only buy 4 at a time. i need my program to not go negative at the end and also i need to stop the user from entering a negative number here is the code.
import java.util.Scanner; public class ticketmaster { public static void main(String[] args) { // Variable decorationuses strings , doubles and final doubles. Scanner in = new Scanner(System.in);
I am writing a code in which a user inputs data as a string and that data must be verified as a valid number. A valid number is anything from 0-100. Then all valid numbers are converted into double numbers.
I am having trouble in how to write the validation part of the code.
Is it suppose to be an if, else statement? And if so how is it suppose to be validated?
String must be 6 characters, first 3 must be letters, last 3 must be digits..Here is my code:
import java.util.Scanner; public class ValidTicket { public static void main (String[] args){ Scanner in = new Scanner (System.in); String id; int c=' ',i; int letterCount=0, digitCount=0; System.out.printf("Enter ticked id
[code]....
However when I run my program, it does not work:After I enter the string nothing happens.
I have problem with this applet. the browser gives page.I don't know wether its not loading or if its extremely slow.Also I am confused on the html part.Should I use tag object or applet and for entering class name data,classid or name.
import java.lang.reflect.InvocationTargetException; public class NewJApplet extends javax.swing.JApplet { @Override public void init() { this.add(fesText); this.add(jButton1); this.add(jLabel1); this.add(jLabel2); this.add(jPanel1);
I am required to make a console calculator that takes the values as strings and turns them into doubles. The user needs to be able to enter something like 3+4+5*9/13 on one line and the application give the answer. As of this point I am currently on at the last section as making the user be able to enter the expression and present the answer. I have added an array list containing + - / * and the same with the numbers 1-9...I now need to actually get the information to all come together. I'm not sure how to do that. I *think* I have all the parts for it to work.
public static void main(String[] args) { String input = ""; // initalize the string boolean isOn = true; // used for the while loop...when false, the // program will exit. final String exitCommand = "Exit"; // exit command
I am trying to write a code that allows you to input 2 lists and it tells you if they are identical or not. However, when I enter my fist list I can only enter two values and then it asks for the next list. How would I fix this to allow me to enter more than two values?
Also, If the second list is different it has me enter more values that list one.
public static void main(String[] args) { Scanner input = new Scanner(System.in); // Enter values for list1 System.out.print("Enter list1: "); int size1 = input.nextInt(); int[] list1 = new int[size1]; for (int i = 0; i < list1.length; i++) list1[i] = input.nextInt(); // Enter values for list2 System.out.print("Enter list 2: ");
If I try CLASSPATH: C:Program FilesMicrosoft JDBC Driver 4.0 for SQL Serversqljdbc_4.0enusqljdbc4.jar I receive a "Could not find or load main class" error.
I think, is of concern to a large Swing-JTabbedPane users and which does not appear in the Sun-Oracle tutorial [URL]
How to add functionality to the hidden 'Action Listener' of JTabbedPane to obtain the two following functionalities, when passing from Tab_Panel_1 to Tab_Panel_2 ?
- To call a home made function as very last task when the 'tab selection change' is triggered and just before control and visibility are leaving Tab_Panel_1.
For example : Calculations and table fillings need to be operated. One assume that the fact of leaving Tab_Panel_1 (by clicking another 'tabPanel') means that the input data in Tab_Panel_1 are completely introduced and that calculations and/or table fillings may occur (to be used by other 'Tab_Panel's).
- At the moment of entering Tab_Panel_21 or Tab_Panel_22, the very first task is to use the previous calculation results and/or table fillings as input parameter of methods own to Tab_Panel_21 and Tab_Panel_22.
For example, these data are further processed and used to feed a graph, different for Tab_Panel_21 and Tab_Panel_22.
The problem is, the JTextArea that's created has a "limited" number of rows - it seems you can still enter more lines than the "limit", but they don't show. I thought it was a problem with the JScrollPane but I'm not so sure...
I have some problems about performing regular expression. In the following code, the output as a result is being "valid last name". But in my opinion, it should be "invalid last name". Because "Doe" has not any space, apostroph or any hypen. Look at the regular expression statement: "[a-zA-Z]+([ '-][a-zA-Z]+)*"
package deneme; public class Deneme { public static void main(String[] args) { String lastName = "Mc-Something"; // Mc-Something if(!lastName.matches("[a-zA-Z]+([ '-][a-zA-Z]+)*")) System.out.println("Invalid last name"); else System.out.println("Valid last name"); } }
I know that the asterisk qualifier means character(s) in any number.(Is this wrong?) So for "Mc-Something", 'M' corresponds to [a-zA-Z], 'c' corresponds to +, - corresponds to [ '-], 'S' corresponds to [a-zA-Z], "o" corresponds to +, and finally "mething" corresponds to *, doesn't they? But for "Doe", there is no any space, apostroph or hypen.
I am creating a JSF 2.0 project, and I am facing a problem when using the rich:pickList (richfaces 4) component with a custom converter.
I can populate the picklist left column rightly. But, when I move some item from left list to the right (by clicking in the pickList "add" button) and I try to submit the form that contains the pickList, I receive the following error message:
"mainForm:picklist: Validation Error: Value is not valid"
I have already overridden the methods equals and hashCode in my model class (Pessoas.java), but the problem remains.
Make a password rule, and take input of the password from the user and compare the password with your rule, if the user had entered valid password then print the message, password valid, else the password is invalid for (the whatever) reason.
Rules:- -Length 8-12 -Should have one numeric character -No Special Character -Atleast one UPPERCASE letter
PHP Code:
import java.util.*; import java.lang.String; import java.lang.Character; public class PasswordSpence { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Please enter a Password: "); String password = input.next(); if (isValid(password)) {
I am currently working on an application with java and I want to do is upload and download details in .xlsx file. Uploading process is successfully worked but the problem is that when I download the file .xlsx with details at opening the file it gives me the following message :
Excel cannot open the file '(filename)'.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Write a program reads in a series of passwords into an array. Store 10 passwords. After creating the password array, have the reader enter a password and see if it is in the array. Fi it is there, print "Valid password" and if it is not there, print "Invalid password."
This is what i have so far
Java Code: public class passwordMatch { public static void main (String [] args){ String [] myArray = new String[10]; myArray[0] = "jasmine22"; myArray[1] = "jackson77";
[Code] .....
It doesn't compile. It gives me error saying .class expected next to String.myArray[]
I'm trying to do a user validation loop that runs until the user enters a valid binary, q, or Q. I think the rest of my program should work as intended, but here is the areas of concern:
public static boolean isBinary(String num) //Check if the entry is binary { for(int i = 0; i < num.length(); i++) { if(num.charAt(i) != 0 || num.charAt(i) != 1){ return false;