Answered step by step
Verified Expert Solution
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.
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 isvalidStep 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