Question: 1. Start with the code below and complete the getInt method. The method should prompt the user to enter an integer. Scan the input
1. Start with the code below and complete the getInt method. The method should prompt the user to enter an integer. Scan the input the user types. If the input is not an int, throw an IOException. Modify the main method so that it catches and prints the IOException. import java.util.Scanner; public class Throwing { public static void main(String[] args) { } int x = getInt(); System.out.println(x); public static int getInt() { // your code goes here } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
