Revise the program in number 9 above to throw a NegativeNumberException if the user enters a negative number.
What will be an ideal response?
```
import java.util.*;
public class GetNumbers2
{
public static void main(String args[]) throws InputMismatchException,
NegativeNumberException
{
Scanner stdin = new Scanner(System.in);
System.out.print("Enter the first non-negative number: ");
int firstNumber = stdin.nextInt();
if(firstNumber < 0)
throw new NegativeNumberException();
System.out.print("Enter the second non-negative number: ");
int secondNumber = stdin.nextInt();
if(secondNumber < 0)
throw new NegativeNumberException();
System.out.println("Your numbers are " + firstNumber + "and " +
secondNumber);
}
}
```
You might also like to view...
Information that if lost could result in the failure of business operations ________ information
Fill in the blank(s) with correct word
The Transform Each dialog box resets itself each time you use it.
Answer the following statement true (T) or false (F)
What is the difference of gotoAndStop and gotoAndPlay?
What will be an ideal response?
Which of the following best represents the minimum requirement for copyright protection? ____
A. Substantially creative or interesting B. "Creative" according to congressional standards C. "Creative" according to Copyright Office standards D. A modicum or small amount of creativity