Question: Create a Java Application, called HundredTest. This Java Application will test numeric integers to determine if they are less than 100. Use the following template
Create a Java Application, called HundredTest. This Java Application will test numeric integers to determine if they are less than 100.
Use the following template for HundredTest.java
package hundredtest; public class HundredTest { public static void main( String args[] ) { try { System.out.println( lessThan100( 1 ) ); System.out.println( lessThan100( 22 ) ); System.out.println( lessThan100( 100 ) ); System.out.println( lessThan100( 11 ) ); } catch( Exception exception ) { System.err.println( exception.toString() ); } } // end main method } // end class Test This application utilizes a lessThan100 method to test whether the number provided is less than 100. Program the static lessThan100 method which accepts an integer number as an argument and returns a formatted String indicating that the number was successfully less than 100 (if it was). If the number is greater than 100, the method should throw an Exception indicating that the number is too large.
Do the following:
1. Create a local Static method called lessThan100(), which accepts an integer parameter. 2. If the number passed to the method is less than 100, the method should output a string The number %d is less than 100. 3. If the number passed to the method is not less than 100, the method should throw an Exception, with the text Number too large.
Test Hasrness:
The HundredTest template includes a test harness which will call you method with different numbers. If the number is less than 100, the output string will be displayed. If the number is 100 or more, an error string will be displayed. Use this harness to test your implementation.
Output (MUST BE EXACT):
The number 1 is less than 100 The number 22 is less than 100 java.lang.Exception: Number too large.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
