Question: I'm doing a grade average script for my class and I can't figure how to get my cross check section to repeat until I have a valid value (Code is listed below). When ran, it allows me to make the correction if the original input is invalid but does this only once. How can I loop until I get a proper response? Thanks in advance!

```
  if (grade1 >= 0 && grade1 <= 100)
     System.out.println("First grade valid.\n");
  else
     {
        System.out.println("Grade invalid.  Re-enter first grade:");
        grade1 = kb.nextDouble();
     }

```

Answer: 
consider

```
grade = -1;
System.out.println("Enter a grade:\n");
grade1 = kb.nextDouble();
if (grade1 >= 0 && grade1 <= 100)
{
    System.out.println("First grade valid.\n");
}
else
{
    while (grade1 < 0 || grade1 > 100)
    {
        System.out.println("Grade invalid.  Re-enter first grade:");
        grade1 = kb.nextDouble();
    }
}

```
Try this:

```
while ((grade = Integer.parseInt(JOptionPane.showInputDialog("Enter a grade"))) < 0 || grade > 100) {
    System.out.println("Invalid grade of: " + grade);
}

```

It doesnt handle letters nicely though, if you enter "a" itll complain and yell at you