IN JAVA PLEASEREALLY NEED HELP Write code to read in an even

IN JAVA PLEASE...REALLY NEED HELP

Write code to read in an even number from the user (using the console and Scanner class). Use a loop to continue to ask for user input until you get an even number. Use a Java-provided exception class to account for the user entering non-numeric data.

Solution

Note:- If you want to print any message when the user enter non-numaric data you can write in the catch block if want to leave it just remove the System.out.println lines present in the catch block and if you want to pass the control back to the input when the user enter non-numaric data just use below code in the place of catch block.

   break  again; //Using labeled break to pass control back to ( again: ) line present in the code.

}

write --> again:

above the satement ---> while(true)

IN JAVA PLEASE...REALLY NEED HELP Write code to read in an even number from the user (using the console and Scanner class). Use a loop to continue to ask for us

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site