Write java program that demonstrates exception handling

Assignment Help JAVA Programming
Reference no: EM13812608

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.

Reference no: EM13812608

Questions Cloud

The bank of america faces a investor : The bank of america faces a investor who would like to borrow 10,000 for a project. If this is a good project, it has 4/5 chance of being succeed which lead to a return of $15,000 and 1/5 chance of being failed which lead to a return of $11,000. On t..
Diagnosing the change : Select a Diagnostic Model that you utilize to review aspects of change activities and actions that have been taken by the companies chosen.
Explain the adverse selection process and also how do financ : Explain the adverse selection process and also how do financial institution hedge interest rate risk?
What about incorporating jit with the inventory philosophy : What about incorporating JIT with the inventory philosophy folks?  Can this help reduce storage and carrying costs?
Write java program that demonstrates exception handling : 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
Optimas award for general hr excellence : In a firm the size of SYSCO with more than 40,000 employees, HR management is making significant contributions to organizational success. As an indication of this success, SYSCO received the Optimas award for general HR Excellence from Workforce M..
European countries split between two loyalties : Are immigrants or children of immigrants settled in European countries split between two loyalties - to their European nation state and to their civilisation? Is the fact that European nation states seem to have problems in transmitting their values ..
Write about two people who have largely influenced your life : Write about two people who have largely influenced your life. Did they influence you in a similar way? Were they similar in ages? Were they from the past or present?
Assignment on family changes since 1960 : FAMILY CHANGES SINCE 1960

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a class harvardlawyer to accompany

Write a class HarvardLawyer to accompany the other law firm classes described in this chapter (Ch 9 of Building java programs; a back to basic approach).

  Write a program to track hourly employee arrival

A company hires you to write a program to track hourly employee arrival and departure times from work. In essence, you are tasked to make an online time clock.

  Write an enhanced for loop

Write an enhanced for loop that counts how many numbers in an ArrayList object named list are negative. Print the count after the loop terminates

  Create a class called scorelist according to the uml diagram

Create a class called ScoreList according to the UML diagram. This class will allow a user to enter up to 100 scores into an array.

  Explain the legal doctrine benefits balancing

Explain the legal doctrine "Benefits Balancing" as it pertains to applying the reasonable standard of care doctrine in the medical fields. Does a defense that the majority of physicians normally do not give a particular diagnostic test in the normal ..

  Write a program that displays the squares

Using a for loop, write a program that displays the squares of all integers greater than 0 and less than or equal to a given number n. Use the c ++ programming language to write the code.

  Determine java application on web and structure functions

Determine the Java application on Web and explain how program structure functions. Explain the application in as much detail as possible.

  Write a program that takes 10 values representin

Using a loop, write a program that takes 10 values representin exam grades (between 0 and 100) from the keyboard and outputs the minimum value, maximum value, and average value of all the values entered. Your program should not accept less than 0 ..

  Program will read parameters plaintext and ciphertextfrom

Specifically, your program will read parameters, plaintext and ciphertextfrom a file named "input.txt" (under the same directory).Then your program needs tocreate a file named "output.txt" (under the same directory) and prints the public key, private..

  The calculator should display the amount of commission

The calculator should display the amount of commission (in dollars), based on the amount of sales entered and the commission rate selected and the total annual compensation.

  Define two different physical representations for strings

Define an ADT for character strings. Your ADT should consist of typical functions that can be performed on strings, with each function defined in terms of its input and output. Then define two different physical representations for strings.

  Design and implement an application to manage a tournament

Design and implement an application to manage a tennis tournament of 16 players - design and implement an application to manage a tournament. Is there anybody who knows how to do this?

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