Question: How do you write your own custom exception class.

I'm trying to write my own exception class that throws an InvalidTestScore.

```
// george beazer
import java.util.Scanner;

public class TestScores{
    public static void main(String[]args){
                int numTests = 0;
                double[] grade = new double[numTests];
                double totGrades = 0;
                double average;   

                Scanner keyboard = new Scanner(System.in);
                System.out.print("How many tests do you have? ");

                numTests = keyboard.nextInt();
                grade = new double[(int) numTests];

                for (int index = 0; index < grade.length; index++){
                        System.out.print("Enter grade for Test " + (index + 1) + ": ");
                        grade[index] = keyboard.nextDouble();        

                        if (grade[index] < 0 || grade[index]> 100){
                                try {
                                  throw new InvalidTestScore();

                                } catch (InvalidTestScore e) 
                                {

                                    e.printStackTrace();

                                }
                        }
                }

                for (int index = 0; index < grade.length; index++){
                        totGrades += grade[index];
                }

                average = totGrades/grade.length;
                System.out.print("The average is: " + average);
        }

}

```

Answer: 
```
class MyCustomException extends Exception
{
    public MyCustomException(String message)
    {
        super(message);
    }
}

```
You simply extend the `Exception` class. Like this:

```
class InvalidTestScore extends Exception {
}

```

Also, here are a few useful constructors that I usually implement.

```
    public InvalidTestScore(String msg) {
        super(msg);
    }

    public InvalidTestScore(Throwable cause) {
        super(cause);
    }

```

Here is the official trail on exception handling: [The Java Tutorials: Lesson: Exceptions](http://download.oracle.com/javase/tutorial/essential/exceptions/)