What's wrong with this code:
DebugTwelve4.java:25: error: cannot find symbol throw(new FixDebugEmployeeIDException("Number too high " + emps[x])); ^ symbol: class FixDebugEmployeeIDException location: class DebugTwelve4 DebugTwelve4.java:36: error: cannot find symbol catch(FixDebugEmployeeIDException error) ^ symbol: class FixDebugEmployeeIDException location: class DebugTwelve4 2 errors Error: Could not find or load main class DebugTwelve4
DebugEmployeeIDException.java:
public class DebugEmployeeIDException extends Exception
{
public DebugEmployeeIDException()
{
super("Debug employee exception");
}
}
-----------------------------------------------------------
DebugTwelve4.java:
// An employee ID can't be more than 999
// Keep executing until user enters four valid employee IDs
// This program throws a FixDebugEmployeeIDException
import java.util.*;
public class DebugTwelve4
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String inStr, outString = "";
final int MAX = 999;
int[] emps = new int[4];
int x;
try
{
for(x = 0; x < emps.length; ++x)
{
System.out.println("Enter employee ID number");
inStr = input.next();
throw(new NumberFormatException("Number format exception"));
{
emps[x] = Integer.parseInt(inStr);
if(emps[x] > MAX)
{
throw(new FixDebugEmployeeIDException("Number too high " + emps[x]));
}
}
}
}
catch(NumberFormatException error)
{
--x;
System.out.println(inStr + "\nNonnumeric ID");
}
catch(FixDebugEmployeeIDException error)
{
--x;
System.out.println("FixDebugEmployeeIDException");
}
for(x = 0; x < emps.length; ++x);
{
outString = outString + emps[x] + " ";
}
System.out.println("Four valid IDS are: " + outString);
}
}