Question
Java Programming Coding Assignment. JGrasp. This assignment focuses on exception processing using the try - catch - finally. You will modify the TryCatchExample program that
Java Programming Coding Assignment. JGrasp.
This assignment focuses on exception processing using the try - catch - finally.
- You will modify the TryCatchExample program that is pasted below these instructions.
- 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.
**Code**
//*************************************************** // // Example file for Exception Processing Assignment // // Author: Kim Cannon // Date: 5/14/15 // //***************************************************
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
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