Question: how do put my program in a while loop to bulletproof the user input. Now, when the user fails to enter a valid number or

how do put my program in a while loop to bulletproof the user input. Now, when the user

fails to enter a valid number or letter the program will display an error MSG and then loop and

prompt them again to try again to input the value correctly.

this is my program it takes your Celsius number and puts it in to a Fahrenheit but i want to make it so it will loop if the person put something in wrong and tell them to try again?

double fTemp;

double cTemp;

Scanner in = new Scanner(System.in);

System.out.println("what is your celius number?");

if(in.hasNextDouble());

cTemp = in.nextDouble();

fTemp = (1.8*cTemp ) + 32;

System.out.println("your temp is" + fTemp);

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 Programming Questions!