hi, i need help adding exceptions to my prgm
<p>I need help adding exceptions to my program.... I have a running program that calculates gpa and standard deviation, but I need to throw an exception AND let the user reenter a <code>String</code> input such as "ABCD" or "F" . I cannot have them enter numbers. my program works based on comparing two strings with the <code>equalsIgnoreCase()</code> method, so how do I add exceptions and let the user  reenter a letter grade if they made a mistake and input a number</p>

<p><strong>Edit:</strong></p>

<p>... oops, soory bout that, so here is my code, where would be a good place to throw an exception. I also need to let the user reenter the grade and have the program working again, instead of terminating after it throws the exception.=)</p>

<pre><code>import java.util.*;
import javax.swing.*;

public class gpaprgm     { 



/**
 * @param args
 */
public static void main(String[] args) { 
    // TODO Auto-generated method stub

    Scanner in = new Scanner(System.in);
    double[] numbers = new double[8]; // create an array to store the grades, call it " numbers"

    double gradesum = 0 ; // intialize the variable gradesum to 0, it holds the numerical value of each letter grade
    double GPA; // initialize the final var. GPA

    // add a try block for exceptions, the following code will be tested
    int j = 1; // initialize the counter "j"
    do{       // use a do while loop to lets the user enter seven grades

    String grade1; // declare a variable to store the dialouge box, where he enters the grades
    grade1 = JOptionPane.showInputDialog(null, "Enter Your subject" + j + "grade"); // create a dialouge box

    if(grade1.equalsIgnoreCase("A") ) // this method compares two strings, checks to see if the input matches the letter" A/a"
    {
        gradesum +=4; // if so, assingn gradesum a value of four
        j++; //  increment "j"
        numbers[j-1]= 4.0; // subtract one from j, so the array doesnt throw an indexoutofbounds exception, also make the value double, becasue GPA is  reported in double values 
    }
    if(grade1.equalsIgnoreCase("B") ) // if input is "B/b", use the same method
    {
        gradesum +=3; // assign grade sum a val of 3
        j++; // increment j

        numbers[j-1]= 3.0; //subtract one from j....make value double, etc.
    }
    if(grade1.equalsIgnoreCase("C") ) // same method, for input of "C/c"
    {
        gradesum +=2; // assign grade sum a val. of 2
        j++; // increment counter j
        numbers[j-1]= 2.0; // subtract one from j.... etc. same reasons as above
    }
    if(grade1.equalsIgnoreCase("D") ) // same method, for input of "D/d"
    {
        gradesum +=1; // assign gradesum a value of 1 for a D grade.
        j++; // increment counter j so loop doesnt go on forever...
        numbers[j-1]= 1.0; // subtract 1 from j, double val... etc.
    }
    if(grade1.equalsIgnoreCase("F") ) // same method,  if input is "F/f" 
    {
        gradesum +=0; // assign  variable gradesum a val of 0, F is FAIL
        j++; // increment counter j
        numbers[j-1]= 0.0; // make val double, subtract one from j....etc.
    }

    }while( j &lt;=7); // we need to have 7 grades, so make the loop have the user enter their grades 7 times

       // the message error appears in a dialouge box

    GPA = gradesum/7; // calulate the Gpa by dividing the total value after all seven grades in the var "gradesum" by seven
    System.out.println( " GPA is " + GPA ); // print out the GPA
</code></pre>
