Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions