Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions