Java program that demonstrates exception handling

Assignment Help Basic Computer Science
Reference no: EM133056218

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.

Reference no: EM133056218

Questions Cloud

Find the maclaurin series : Find the Maclaurin series up to and including the term - Let w be one of the non-real solutions of the equation
What is the present value : Question - Assuming the interest rate is 4%, what is the present value of a $1,800 payment you will receive in 4 years, 6 years, 10 years
Monitor security risks across the enterprise : Describe at least 2 identity and access management tools needed to measure and monitor security risks across the enterprise.
Determine the correct amount of net income : Accrued expenses of $11,500 were omitted at the end of 1996. Determine the correct amount of net income for 1995 and 1996
Java program that demonstrates exception handling : Write a Java program that demonstrates exception handling. calculate a total that equals the sum of the three variables divided by the third input variable.
Are index funds more risky : Are index funds (ETFs) more risky? What is the difference between market risk and active risk?
What is the number of issued and outstanding ordinary shares : Monggo Company reported the following equity accounts: Preference share capital, par value P15 2,550,000, What is the number of issued and outstanding ordinary
What is the external financing needed : The most recent financial statements for incredible edibles, Inc are shown here ( assuming no income taxes):
What is the value of firm : Leisure Vacations is an unlevered firm with aftertax net income of $57,980, a cost of capital of 13.2 percent, and a tax rate of 35 percent.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Prints the equivalent total number of seconds

Write an application that reads values representing a time duration in hours, minutes, and seconds, and then prints the equivalent total number of seconds.

  Code of a c program about sorting a array

When will code of a C program about sorting a array, what operation does machine do first to sort the array first, sorting or searching the array elements?

  Draw a dependency diagram to show functional dependencies

This assessment item is designed to test your understanding of more advanced database design, your ability to use an iterative approach to modelling, and to examine data problems due to redundancy.

  Find out how to configure an http server

Decide if such a feature is part of the protocol or part of an implementation, or is technically even permitted by the protocol. (Documentation for the apache HTTP server can be found at www.apache.org.)

  Requirements for equal employee opportunity

Ways Walmart is trying to meet legal requirements for equal employee opportunity? In what ways does it actions exceed legal requirements? What can Walmart's HR managers do to help the company improve its performance in complying with EEO laws?

  Organization confidential information

Employees can compromise an organization's confidential information, deliberately or inadvertently, through their network and Internet usage. Such concerns prompt companies to introduce security monitoring of their employees. However, they have to..

  Assessment for a typical manufacturing facility

Determine the top five IT assets to include in a risk assessment for a typical manufacturing facility.

  Prayer group reflection essay

Ministry requires discipline and ministers must grow in their spiritual lives through spiritual disciplines. Ministers must also know how to help those who are entrusted in their care to grow spiritually. Consider prayer group meeting on a weekly bas..

  Discuss importance of information protection

Discuss the importance of Information Protection. What are the consequences for not protecting the organizational or personal data and information?

  Type of unemployment on business

Discuss different types (frictional, structural and cyclical) of unemployment and the impact of each type of unemployment on business.

  Show state-transition table for the traffic light

Show a state-transition diagram and a state-transition table for the traffic light. Let the input be the state of the buttons (1 if either button has been pushed, 0 otherwise), and assume that a clock pulse occurs once every 10 seconds. (In other ..

  Percent rate of return

Thereafter, it will pay no dividends. If you require 12 percent rate of return, how much is this stock worth to you?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd