Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction to JAVA Project: I need help with my homework this week. Given a program (Test.java) that gets two numbers from user input and then

Introduction to JAVA Project: I need help with my homework this week.

image text in transcribed

image text in transcribed

image text in transcribed

Given a program (Test.java) that gets two numbers from user input and then carries out a division, revise it to handle exceptional inputs. The given program does those: Prompt 1 Input 1 Prompt 2 Input 2 Calculation For the purpose of this project, input 1 should be a double value and input 2 should be a non-zero int value. Upon an invalid input, your program should allow a user to re-enter a piece of data. This would require a loop to validate each input and allow for additional data entry. We need a loop instead of an if-else as you can't assume a second input would be valid. You will complete this exercise using two approaches: 1. use try-catch. 2. Use defensive coding. Save each version in a different source code file. Version A: Try-Catch Because invalid data must be removed from an input stream object before additional input could happen, you need to read in each number as a string and then parse the data in the string. Follow this pseudo code for the try-catch version: Do // loop if wrong type of input isvalid

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

What ways can the cost of a process be improved?

Answered: 1 week ago

Question

=+21.18. Use (21.28) to find the generating function of (20.39).

Answered: 1 week ago

Question

Describe the linkages between HRM and strategy formulation. page 74

Answered: 1 week ago

Question

Identify approaches to improving retention rates.

Answered: 1 week ago