Could someone explain to me how I could put a conditional of grade can only be 0 or greater or 100 or less. I've tried the statement inside the while loop, but then the average doesn't come out correct. I've put it outside the loop, but that doesn't seem to work either.
while (!gradeInput.equals(SENTINEL)) {
try {
int grade = Integer.parseInt(gradeInput);
sum += grade;
count++;
}
catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null,"Error! only numeric values.");
}
gradeInput = JOptionPane.showInputDialog("Enter exam grade (or -1 to end the program):");
}