Create a new project in your ide named exceptionhandler

Assignment Help Programming Languages
Reference no: EM13781317

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: EM13781317

Questions Cloud

Short notes on develop an internet strategy : What Internet business model would be appropriate for the company to follow in creating a Web site and why?
Formulate a hypothesis statement concerning : The numbers in the "No Meds" column indicate the number of months free from addiction without medication. The numbers in the "Meds" column indicate the number of months free from addiction while taking medication. I recommend changing the measur..
A single step from the given premises : Given the following premises: Q > (A v ~T), T, A v ~T, Select the conclusion that follows in a single step from the given premises. A.Q > (~~A v ~T) 1, DN B.(A v ~T) > Q 1, Com C.(Q > A) v ~T 1, Assoc D.Q 1, 3, MP E.A 2, 3, DS
Explain how a particular text produces meaning : explain HOW a particular text produces meaning through its arrangement and organization of signs. It carefully examines the different signs that organize the text
Create a new project in your ide named exceptionhandler : 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.
Describe one way which laws are made in australia : Describe one way which laws are made in Australia. Name the three tiers of government in Australia and give information as to how each of these impacts education, special needs students and schools. What does duty of care mean to you in your work p..
What is the basic difference between socrates : What is the basic difference between Socrates' views of the good life and Buddha's? Support your answer with an argument.
Assignment on creating a small network : Creating a Small Network
What kinds of adjustments do chinese companies : Read the article and consider the issues involved in Chinese acquisitions and mergers abroad. What kinds of adjustments do Chinese companies need to make to succeed in these ventures

Reviews

Write a Review

Programming Languages Questions & Answers

  Why wont the following program compile correct it so it

question why wont the following program compile?class exception3 public static void mainstring args if

  Program to allot new value to first element of array

Write the single statement which assigns new value to first element of array. This new value must be equal to twice value stored in the last element of the array.

  Write program to allot seats on each flight of airline-s

Program the new system you are to write program to allot seats on each flight of airline's only plane(capacity: 10 seats)

  Write a program to ask the user to enter the amount spent

Write a program to ask the user to enter the amount spent on food and Gas for each day of the week. Count and display the number of days the user spent more than 20 dollars per day on food and more than 10 dollars/per day on gas.

  Write program to open the text file-reads its contents

Write down a program which opens the text file and reads its contents into the stack of characters. Program must then pop characters from stack and save them in second text file.

  Write program to show percentage of calories come from fat

Write a program which asks user to enter number of calories and fat grams in a food item. The program must display percentage of the calories that come from fat.

  Write and test code to create window with green background

Use Processing to write and test code that meets the requirements below. Create a 600x400 window with a green background (using 64 as the "amount" of green to draw).

  Application to input five numbers by one-dimensional array

Use a one-dimensional array to solve the following problem: Write an application that inputs five numbers, each between 10 and 100, inclusive.

  Write pseudocode for the function of nonplayercharacter

Identify two additional classes needed for a more detailed class model. Their names should be descriptive enough to indicate their overall responsibilities.

  Explain one new concept learned about arrays

Explain one (1) new concept that you have learned about arrays and one (1) new concept that you have learned about loops as a result of reading the assigned article.

  Design the swing applet and html test file

You can download sound clips and graphics images from Internet to use in the program. Design the Swing applet named JPartyPlanner and HTML test file to run Swing applet.

  Create the program uses two arrays to hold employee names

Create the program which uses two arrays: one to hold employee names and one to hold employee salaries (standard US currency, two decimal points). The program must prompt user to enter employee names.

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