-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebugTwelve4.java
More file actions
40 lines (40 loc) · 1.19 KB
/
Copy pathDebugTwelve4.java
File metadata and controls
40 lines (40 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// An employee ID can't be more than 999
// Keep executing until user enters four valid employee IDs
// This program throws a FixDebugEmployeeIDException
import javax.swing.*;
public class DebugTwelve4
{
public static void main(String[] args)
{
String inStr, outString = "";
final int MAX = 999;
int[] emp = new int[4];
for(x = 0; x < emp.length; ++x)
{
inStr = JOptionPane.showInputDialog(null, "Enter employee ID number");
throw
{
emp[x] = Integer.parseInt(inStr);
if(emp[x] > MAX)
{
throw(new FixDebugEmployeeIDException("Number too high " + emp[x]));
}
}
catch(NumberFormatException error)
{
--x;
JOptionPane.showMessageDialog(null, inStr + "\nNonnumeric ID");
}
catc(FixDebugEmployeeIDException error)
{
--x;
JOptionPane.showMmrge");
}
}
for(int x = 0; x < emp.length; ++x)
{
outString = outString + emp[x] + " ";
}
JOptionPane.showMessageDialog(null, "Four valid IDS are: " + outString);
}
}