Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

post solution and explanation as an image or snippet if possible (a) Write an unchecked exception class WeirdInputException. The class has two public constructors: one

image text in transcribed

post solution and explanation as an image or snippet if possible

(a) Write an unchecked exception class WeirdInputException. The class has two public constructors: one that does not take any parameters, and one that takes a parameter of type String. Both constructors are supposed to call the respective corresponding superclass constructor for their parameters. (b) Write a static Java method without any parameters that reads a series of numbers of type int from the keyboard. - Before each input, the method prints a message to ask the user for a number. - If an input is not an int number, the method throws a WeirdinputException. - If the user enters 0 , the method finishes. - Otherwise: - if the current number is the same as the previous number, "Same" is printed; - if the current number is greater than the previous one, "Up" is printed; - if the current number is less than the previous one, "Down" is printed. - The method makes no response at all to the very first number. For example, the output for the inputs 9,8,8,5,10,10,0 would be Down, Same, Down, Up, Same (comparing, in turn, 9 and 8, 8 and 8,8 and 5, 5 and 10, 10 and 10 ). The dialogue with the user would look as follows: Enter the next number ( 0 to finish): 9 Enter the next number ( 0 to finish): 8 Down Enter the next number ( 0 to finish): 8 Same Enter the next number ( 0 to finish): 5 Down Enter the next number ( 0 to finish): 10 Up Enter the next number ( 0 to finish): 10 Same Enter the next number ( 0 to finish): 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions