Assignment Description

Assignment Details

For this project, you will write a Java program that demonstrates exception handling. To facilitate this, you will need to collect input from a user, perform calculations, and send output to the screen. Exception handling will catch any input and calculation errors that may arise. For this project you will need the following variables (all integers): Three to store the input from the user, one to store the sum, and one to store the total. Remember to set their initial values to zero.

Create a new Java project. Write code to prompt the user to enter a number, then repeat this for a second number and a third. As each number is entered, store it in a variable. In each case, use an Input Mismatch Exception handler to catch when the user enters a letter instead of a number. Use the Catch block to inform the user that they should only enter numbers.

When all three numbers have been stored in variables, add the three numbers (their variables) together and store the sum in another variable.

Next, calculate a total that equals the sum of the three variables divided by the third input variable. (Put another way, divide the sum of the numbers by the third number that the user entered.) Use an Arithmetic Exception to handle situations where the third number that was entered by the user was a zero, informing the user that the program has produced a “Divide by zero error.”

Document your code thoroughly with code comments and be sure to explain how each exception works and what it is doing.

Tip: No custom classes, loops, or IF/ELSE statements are needed for this assignment.
Tip: Remember to initialize your variables!

Computer Science homework help


10% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET10 to claim 10% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.