Question: Integer applicantAge is read from input. Use multiple exception handlers to: Catch an InputMismatchException and output Input type error: Integer required when applicantAge is not
Integer applicantAge is read from input. Use multiple exception handlers to:
Catch an InputMismatchException and output "Input type error: Integer required" when applicantAge is not an integer.
Catch an Exception and output the Exception's message when applicantAge is negative.
End each output with a newline. import java.util.Scanner;
import java.util.InputMismatchException;
public class ApplicantAge
public static void mainString args
Scanner scnr new ScannerSystemin;
int applicantAge;
try
applicantAge scnrnextInt;
if applicantAge
throw new ExceptionValue error: Nonnegative value required";
System.out.printValid input: ;
System.out.printlnApplicants age is applicantAge;
Your code goes here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
