Im having problems with creating a while loops with if else


Im having problems with creating a while loops with if else structures. My program first presents a menu to the user: (A) to pan a room or (Q) to quit the program which is working great, its my outside loop that will be asked again after every room is planned until the user wants to quit. My question is i have to validate all user input, how can make it easy to test for chars. part of my code:

//Present Main Menu 

System.out.println("nt Thank you "+userName+(", what would you like to do?n"));

System.out.println("Select (A) To Plan your room and recieve a quote.");

System.out.println("Select (Q) To Quit this program.nn");

System.out.print("Please select here: ");

validateMenuSelection = Character.toUpperCase(input.nextLine().charAt(0));

//Start of the central processing 

//Validate Main Menu 

while(validateMenuSelection != 'A' && validateMenuSelection != 'Q')

{

  System.out.println("Invalid input "+userName );

System.out.println("Select (A) To Plan your room and recieve a quote.");

System.out.println("Select (Q) To Quit this program.nn");

System.out.print("Please select here: ");

validateMenuSelection = Character.toUpperCase(input.nextLine().charAt(0));

}

while(validateMenuSelection != 'Q')

{

System.out.println("Lets Begin planning your room "+ userName );

System.out.println(" What is the Length of your entire room?" );

validateLengthSelection = input.nextDouble();

input.nextLine();

while ( Double.isNaN(validateLengthSelection))

{

System.out.println("Negative numbers are not valid "+ userName);

System.out.println(" Please enter the length of your entire room.");

validateLengthSelection = input.nextDouble();

input.nextLine();

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Im having problems with creating a while loops with if else
Reference No:- TGS02892464

Now Priced at $15 (50% Discount)

Recommended (92%)

Rated (4.4/5)