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 

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

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 Computer Network Questions!