Question: JAVA VALIDATION QUESTION Modify the below JAVA code to ensure a user can only enter an integer. public class Test { public static void main(String[]
JAVA VALIDATION QUESTION
Modify the below JAVA code to ensure a user can only enter an integer.
public class Test {
public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter the amount of subjects that you are studying: "); int amount_of_subjects; amount_of_subjects = in.nextInt();
System.out.println(amount_of_subjects);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
