Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started