Details of this Paper

ITS320 week7 Cirtical thinking

Description

solution


Question

;;? A screen snapshot of your Java source code (all file(s) shown separately) displayed in the IDE or Windows editor showing a successful compilation, if possible (only the beginning of the source file(s) are necessary).;? A listing of your entire source code file(s).;import java.util.InputMismatchException;import java.util.Scanner;/*;the driver class called Program5;* @author xyz;*/;public class Program5;public static void main (String[] args);// The driver class should instantiate a Verify object with a range of 10 to 100.;Verify verify = new Verify(10, 100);//It should then do the following;// Use a Scanner to read the user input as an int.;Scanner input = new Scanner(System. in);int num = 0;boolean good = true;//You can ensure that an int was entered because the nextInt method;//in the validate class throws an InputMismatchException if any non digits are entered.;do;good = true;try;//Prompt the user to input a number within the specified range.;System. out.print("Input a number between 10-100 inclusive: ");num = input.nextInt();catch (InputMismatchException ex);input = new Scanner(System. in);System. out.println("Please enter numeric integer value.");good = false;while (!good);try;//Call the validate method to validate that the number is within the range.;verify.validate(num);//print the value if it is within the range.;System. out.println("Number entered: " + num);catch (NumberNegativeException ex);//Print an appropriate error message if the value is not within the range;System. out.println(ex.getMessage());catch (NumberLowException ex);//Print an appropriate error message if the value is not within the range;System. out.println(ex.getMessage());catch (NumberHighException ex);//Print an appropriate error message if the value is not within the range;System. out.println(ex.getMessage());/*;a class called Verify that will be used to validate that a number is within a specified range;*/;public class Verify;private int minimum;private int maximum;/**;* one constructor that has 2 int parameters.;* @param minimum - minimum number in the range;* @param maximum - maximum number in the range.;*/;public Verify (int minimum, int maximum);this. minimum = minimum;this. maximum = maximum;/**;* The validate method will have a single parameter of data type;* @param number - the number that is being validated.;*/;public void validate (int number) throws NumberNegativeException, NumberLowException, NumberHighException;// If the value of the parameter is less than zero, the method should throw a NumberNegativeException;if (number < 0);throw new NumberNegativeException("Exception: Number is negative");// If the value is less than the minimum value of the range, it should throw a NumberLowException.;if (number maximum);throw new NumberHighException("Exception: Number is greater than the maximum value of the range");/*;NumberNegativeException should be subclassed from NumberLowException;*/;public class NumberNegativeException extends NumberLowException;public NumberNegativeException (String msg);super (msg)

 

Paper#64114 | Written in 18-Jul-2015

Price : $32
SiteLock