Question
The width and length must be integers (whole numbers) greater than 0. Height may be 0, otherwise it must be a positive integer. Create 2
The width and length must be integers (whole numbers) greater than 0. Height may be 0, otherwise it must be a positive integer.
Create 2 exception classes that will throw errors (see the lecture notes class IntegerNotGreaterThan10Exception) a. LessThanOrEqualToZeroException b. LessThanZeroException 2. Write an executable class called InputWidthLengthHeight which asks the user to inputs value for three variables of type integer: height, length, width. a. Print your name, Lab number, and date as the first three lines of output. Hard-code the date...do not use the system date b. You will want to create two public static void methods in this class that will test the data and throw the correct exception. i. public static void lessThanOrEqualToZeroException(String myField, int myNumber throws LessThanOrEqualToZeroException ii. public static void lessThanZeroException( String myField, int myNumber ) throws LessThanZeroException iii. myField is the current field that is attempting to be input, i.e. width, length, height iv. myNumber is the value that the user has input c. Input data i. If the users data causes an exception your program should respond by explaining the error and asking the user to reenter the inappropriate value. ii. Handle any exceptions which might occur. Your program should not blow up or crash but continue to run until all three values contain an appropriate value. iii. Do not use generic exception handling. Set up a catch block for each specific exception you encounter 1. height must be greater than or equal to zero: catch LessThanZeroException 2. width and length must be greater than 0: catch LessThanOrEqualToZeroException 3. non-numeric or decimal inputs: catch InputMismatchException iv. All three values must be input with valid data. Once all three value are entered then display a message that alerts the user to the successful input. v. d. Calculate and display the width to length ratio(width divided by length)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started