i'm write a program that asks for a password then if correct will go into a while loop, but for some reason whenever i execute the code and enter the right pass, nothing happens. heres what i've been working on:

/*
  This program will simulate a program that could
  be used by an SAT tutoring company.
 */

 public class sat_tutor
 {
 	public static void main (String [] args)
 	{
 		EasyReader console = new EasyReader();
 		final String password = "1";
 		String passwordattempt;
 		String buffer;
 		int selection;
 		System.out.print("Please enter the password to enter the system: ");
 		passwordattempt = console.readLine();
 		buffer = console.readLine();

		boolean menu1 = false;
 		boolean menu2 = false;
 		boolean menu3 = false;

 		while(passwordattempt.equals(password));
 		{
 			System.out.println("S A T   H E L P   B I L L I N G");
 			System.out.println("            M E N U");
 			System.out.println("");
 			System.out.println("[1] TUTOR'S INFORMATION");
 			System.out.println("");
 			System.out.println("[2] STUDENT INFORMATION");
 			System.out.println("");
 			System.out.println("[3] STUDENT RECEIPT");
 			System.out.println("");
 			System.out.println("[4] QUIT PROGRAM");
 			System.out.println("");
 			selection = console.readInt();

 			if(selection == 1)
 			{
 				String tutorname;
 				int code;
 				System.out.print("Please enter your name: ");
 				tutorname = console.readLine();
 				buffer = console.readLine();
 				System.out.print("Please enter your personal 4-digit code: ");
 				code = console.readInt();
 				if(((code / 1000) == 7) && ((code - 9) % 10) == 0)
 				{
 					System.out.println("Code has been validated");
 					menu1 = true;
 				}
 				else
 				{
 					System.out.println("Invalid code.");
 				}
 			}
 		}
 	}
 }

i've given the code to my friend and he says that it runs fine on his computer and we both use the same compiler/ide (jcreator). i'm thinking that its not a problem w/ my code but w/ my computer. anyone have any ideas?

First question is what is your 'EasyReader' class? Can you post the code for it? I suspect the return from "passwordattempt = console.readLine();" is corrupt, but since console is from the 'EasyReader' class I can't tell.

Your complier is skipping your while loop because you have a semicolon after the while loop, this tells the program that that line is ended and so it doesn't execute the statements inside.

Dooh! Darn semicolon! Missed that one......hehe

Great eyes shdwdrgn517!

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.