Question: Jump to level 1 The while loop reads values from input until two integers are read. Complete the exception hanc InputMismatchException exception and: Output Discarded
Jump to level
The while loop reads values from input until two integers are read. Complete the exception hanc InputMismatchException exception and:
Output "Discarded bad input value for postal ZIP code". End with a newline.
Discard the invalid input.
Ex: If the input is then the output is:
Postal ZIP code is
Postal ZIP code is
Processed two valid input values
Ex If the input is Q then the output is:
Postal ZIP code is
Discarded bad input value for postal ZIP code
Postal ZIP code is
Processed two valid input values
Note: Each value read from input is on one line.
import java.util.Scanner;
import java.util. InputMismatchException;
public class TwoPostalZipCodes
public static void mainString args
Scanner new Scanner
System.in;
int postalZipCode;
int validCount ;
while validCount
try
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
