java a. The user is prompted to enter an integer. If they enter something other than an integer, you want to set the int variable input to -1. Complete the try-catch statement below to accomplish this, leaving the Scanner object named scanIn ready to read in another value. Note: Follow the Java style guide for spacing. try { input = scanIn.nextInt(); } catch (InputMismatchException ime) { input = -1; ________________________ } b. Complete the following do-while loop so that it continues to prompt the user until the value of input is greater than 10. Assume that the Scanner object scanIn is already instantiated to read from the keyboard. int input; do { System.out.print("Input an integer larger than 10: "); input = scanIn.nextInt(); ___________________
java
a.
The user is prompted to enter an integer. If they enter something other than an integer, you want to set the int variable input to -1. Complete the try-catch statement below to accomplish this, leaving the Scanner object named scanIn ready to read in another value.
Note: Follow the Java style guide for spacing.
try {
input = scanIn.nextInt();
} catch (InputMismatchException ime) {
input = -1;
________________________
}
b.
Complete the following do-while loop so that it continues to prompt the user until the value of input is greater than 10. Assume that the Scanner object scanIn is already instantiated to read from the keyboard.
int input;
do {
System.out.print("Input an integer larger than 10: ");
input = scanIn.nextInt();
___________________
Step by step
Solved in 2 steps