Reference no: EM131257600
This snippet of code allows the user to input two integers and then divides them. Unfortunately, it is error prone (ie allows a divide by zero error) and does not give the user much feedback when the two numbers are not evenly divisible.
Scanner userIn = new Scanner(System.in);
int numerator, denominator;
int result;
numerator = userIn.nextInt();
denominator = userIn.nextInt();
result = numerator / denominator;
First, separate the input function from the math function, placing the input function into a class with a main method, and the math function into a the class MyMath.
Next, declare two exception classes, a ZeroDenominatorException which should be a subclass of RuntimeException and a NotEvenlyDivisibleException which should be a subclass of Exception.
Next, within the MyMath class method that divides the two numbers, throw a ZeroDeonminatorException if the denominator is zero and throw a NotEvenlyDivisibleException if the two numbers are not evenly divisible (ie there is any remainder).
Finally, in the main method, add the error handling code necessary to provide feedback to the user when the division cannot be done, or when the division will end in a remainder that would not be shown
Installing the new operating system
: Your supervisor tasked you with installing the new operating system from Microsoft on all desktops and laptops in the company.
|
Determine the equilibrium price and quantity
: Determine the implications for each of the computed elasticities for the business in terms of short-term and long-term pricing strategies. Provide a rationale in which you cite your results.
|
Determine the percent of failures
: A manufacturer of disk drives for notebook computers wants an MTBF of at least 50,000 hours. -Determine the Percent of failures, Number of failures per unit-hour and MTBF at this point in the testing.
|
What is the importance of market segmentation
: What are the characteristics of markets and market segments? What is the importance of market segmentation? What are some of the criteria for successful marketing segmentation
|
Snippet of code allows the user to input
: This snippet of code allows the user to input two integers and then divides them. Unfortunately, it is error prone (ie allows a divide by zero error) and does not give the user much feedback when the two numbers are not evenly divisible.
|
Save for retirement
: Wendy decides to save for her retirement starting on her 25th birthday. She puts $1,000 a year in an investment that earns 10% a year compounded annually. She does this for 20 years (she is then 45, and has invested $20,000) and then stops adding mor..
|
Determine the various ways to integrate technology
: Explain at least three (3) reasons why these particular tools are considered an emerging technology to the educational or training setting you have chosen. Using the current literature, support your rationale.
|
How leaders influence employees to achieve goals
: Draft three interview questions that address how leaders influence employees to achieve organizational goals
|
Exponential back-off algorithm
: Two CSMA/CD stations are trying to transmit a few long video files. After each frame is sent, they contend for the channel using binary exponential back-off algorithm.
|