import java.util.*;
class Project11
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int num = 0;
do
{
System.out.print("Enter int in range 1..100 inclusive: ");
try
{
num = input.nextInt();
if(num < 1 || num > 100)
throw new NumberOutOfRangeException();
}
catch(InputMismatchException e)
{
System.out.println("Input was not an integer");
}
catch(NumberOutOfRangeException e)
{
//System.out.println(e);
}
catch(Exception e)
{
System.out.println(e);
System.exit(0);
}
}while(num < 1 || num > 100);
System.out.println("Thank you. You entered " + num);
}
class NumberOutOfRangeException extends Exception
{
String s;
public NumberOutOfRangeException()
{
s = "Number out of range. Must be in 1..100";
}
public String toString()
{
return s;
}
}
When I put the NumberOutOfRangeException class above main I do not get that error. How do I make it so it can go beneath main without getting that error? Ive tried changing/adding some brackets in different places but I still get that error regardless. Thanks for any help!