Write code to accept numbers from the user

Assignment Help Other Subject
Reference no: EM131873233

Question: Errors occur in programs, and there are two ways to address the problems. The first is to try to write code that checks for errors and then deals with them. For example, you can use error checking to see if a user selected a valid menu option after making a selection. Error checking tries to prevent errors from occurring. Another method is to go ahead and let errors occur but to handle them gracefully before they can affect the operation of the program. This method, called exception handling, will be the focus of this project.

For this project, you will write a Java program that demonstrates exception handling. Your program will accept from the user ten values and place those numbers in an array. The numbers in the array will be added together and the result displayed to the user. The program will also perform division. The program should compare the values for elements 1 and 2 in the array and divide the larger number by the smaller number. It should compare the values for all odd/even elements and divide the larger by the smaller value. The program should use exception handling to avoid division by zero errors or out of range errors (dictated by the variable's data type) which would cause the program to stop due to the error. The program should prompt the user for a second set of ten numbers. When the user enters 9999 the program should terminate normally.

For this project, do the following:

• Create a new project in your IDE named "ExceptionHandler."

• Write code to accept numbers as described above from the user. Your code should ensure that only numbers are accepted.

• Write code to add all values together and to divide larger numbers by smaller numbers in odd/even elements. Results should be displayed.

Loop to get another set of ten numbers from the user until the user enters 9999 as the first number.

• Use exception handling to handle division by zero and out of range exceptions.

• In the catch blocks, be sure to display the cause of the exception to the user.

• Make sure your exception handler will handle any other errors as a default.

• Create a UML activity diagram that illustrates how your program works. Your diagram must include all the data items in your program.

• Use good comments to describe how the program works.

• Make sure the program runs correctly before submission.

• Create a zip that includes your project folder and Word document, and upload it to the course portal.

Reference no: EM131873233

Questions Cloud

What is the npv of test-marketing before going to market : What is the NPV of test-marketing before going to market?
Make his first savings contribution : Caruso is planning to save 2,683.27 dollars every quarter for 12 years. He plans to make his first savings contribution in 3 months from today.
What is the npv of going directly to market : What is the NPV of going directly to market?
Company is deciding whether to invest in new machine : Your company is deciding whether to invest in a new machine. What is the NPV if the company decides to wait 2 years to purchases the machine?
Write code to accept numbers from the user : Errors occur in programs, and there are two ways to address the problems. The first is to try to write code that checks for errors and then deals with them.
Make annual scholarship payments forever : Imari wants to establish a charitable foundation that will make annual scholarship payments forever.
Variable cost per unit projection : what is the sensitivity of OCF to changes in the variable cost per unit projection?
Discuss the presidential role in health policy : There have been discussions in regards to the Patient Protection and Affordable Care Act (PPACA) and other actions that in recent years President(s).
Sensitivity of npv to changes in the units sold projection : In dollar terms, what is the sensitivity of NPV to changes in the units sold projection?

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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