Question: language: java topics: do while loop, while loop, user input, exception and try catch block. question: how do you repeat a question if user input

language: java topics: do while loop, while loop, user input, exception and try catch block.

question: how do you repeat a question if user input was wrong? using do while loop and while loop? please display result in console.

example: the first question is enter a int number. if you dont enter a int number. that question repeats. the next question is enter a double number, if you dont enter that double number, the second question repeats. you cant't go to next question until previous question had correct user input.

for this to happen . do you do a nested a while or do loop? the next question depends on whether the previous question had a correct user input. so if the second question had incorrect input, only that second question repeats, not both the second and first question.

format example you can use as guide : boolean valid = true;

do { system.ou.println("Enter a int number"); int number = input.nextInt(); input.nextLine(): system.out.println("Enter a double number"); double num2 = input.nextDouble(); input.nextLine();

valid = false;

}while(Valid);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!