Question: Write a program that prompts the user to read two integers and displays their sum. If anything but an integer is passed as input,

Write a program that prompts the user to read two integers and

Write a program that prompts the user to read two integers and displays their sum. If anything but an integer is passed as input, your program should catch the Input MismatchException that is thrown and prompt the user to input another number by printing "Please enter an integer." SAMPLE RUN #1: java InputMismatch Interactive Session Standard Input Standard Error (empty) Standard Output Hide Invisibles Highlight: NoneStandard Input OnlyPrompts OnlyStandard Output w/o PromptsFull Standard OutputAllShow Highlighted Only Enter-an-integer:2.5. Please enter-an-integer. Enter-an-integer-4.6. Please enter-an-integer. Enter-an-integer:hello! < Please enter-an-integer. Enter-an-integer:7- Enter-an-integer:5.6- Please enter-an-integer. Enter-an-integer:9.4 Please enter-an-integer. Enter an integer:10 17

Step by Step Solution

3.44 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilInputMismatchException import javautilScanner public class InputMismatch p... View full answer

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 Programming Questions!