Write code to prompt the user to enter a number

Assignment Help Basic Computer Science
Reference no: EM132926473

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.

Question 1: 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.

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

Question 3: 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."

Reference no: EM132926473

Questions Cloud

How much is the consolidated gain or loss : Borland holds the land until December 31, 2019 when it sells it to third parties for $150,000. How much is the consolidated gain or loss for 2019
Modify the rotating cube program : Modify the rotating cube program from your assignment to build a logo. Use the program wherein the mouse moved the cube in different directions
What is deprival value : What is deprival value? How useful is an alternative valuation such as deprival value for Tootlealong Ltd's managers
How the knowledge or theories of the course : How the knowledge or theories of the course (Security Architecture and Design) have been applied or could be applied in a practical manner
Write code to prompt the user to enter a number : 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.
What is Fox net loss on their income statement : For each of the past 2 years, 2018 and 2017, Fox's taxable income was $250,000 with a 25% tax rate. What is Fox's net loss on their 2019 income statement
How often should a plan be reviewed and be whom : Discuss options for testing a BCP/DRP plan (Describe at least two options). Of your options, which would provide the greatest value?
Calculate the present value of the lease payments : Montevallo estimates that it is probable that it will have to pay $15,000 cash due to the residual value guarantee. Calculate present value of lease payments
Provide a brief description of each process : Provide a brief description of each process. The movie "The Martian" can be viewed through the framework of project management.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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