Writing a for loop storing numbers to an array and asking for numbers via JOptionPane. Using System.out, everything runs as expected in the console. When using JOptionPane, the box opens on the first, third, fifth, and seventh iterations but does not store data. Data must be entered into the console where it is stored and must be entered seven times. JOptionPane works as expected when the array is commented out. How do I get JOptionPane to work correctly?
for(int i = 0; i < 7; i++) {
// System.out.println("Enter element");
String input = JOptionPane.showInputDialog("Enter number of advising appointments");
appointmentNumber[i] = scanner.nextInt();
}
Figured out a solution to my problem. Not sure what was wrong but the program runs at needed now.
for(int i = 0; i < NUM_DAYS; i++) {
// System.out.println("Enter element");
int input =Integer.parseInt(JOptionPane.showInputDialog("Enter number of advising appointments "));
appointmentNumber[i] = input;
if (input < MIN_NUM_APPOINTMENTS) {
throw new Exception("Only Positive Numbers and no letters.");
}
JOptionPane.showMessageDialog(null, e.getMessage());
}