Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package hundredtest; public class HundredTest { public static void main( String args[] ) { try { System.out.println( lessThan100( 1 ) ); System.out.println( lessThan100( 22 )

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

image text in transcribed

Module 13 Lab: Exception Handling Lab Objective The objective of this assignment is to teach the student how to define and use their own exception handler for testing if a user entered a number out of range. Lab Instructions Create a Java Application using Netbeans, called HundredTest. This Java Application will test numeric integers to determine if they are less than 100. Download the Java Application template, HundredTest.java, from Canvas under Module 13: Lab. Copy and Paste the source code into your newly created Java Application. 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. Additional Information Create a local Static method called 'lessThan100(), which accepts an integer parameter. If the number passed to the method is less than 100, the method should output a string "The number %d is less than 100" 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 Harness 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 Information 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

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

Step: 3

blur-text-image

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions