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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started