Question: You will modify the TryCatchExample program that is attached to this assignment. You will modify the program to input an integer value and a double

You will modify the TryCatchExample program that is attached to this assignment. You will modify the program to input an integer value and a double value. Each input should display a prompt indicating the type of data to be input. You will include try - catch clauses that will handle the following conditions: invalid integer values was input, an invalid double value was input, and a divide by zero operation. The code for exception processing should be: invalid integer input should result in an error message and a prompt for another integer, an invalid double value should result in an error message and a prompt for another double, and a divide by zero should result in an error message and the termination of the program. All input should be done from the keyboard using a Scanner object.

Included code below:

import java.util.Scanner;

public class TryCatchExample {

public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Input integer value: "); int in = input.nextInt(); System.out.println("Value input was: " + in); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!