I have been writing a simple calculator program (no GUI) and one thing I have noticed is that while the calculator is in a calculation mode (adding/subtracting/etc.), if the user inputs a word or some invalid symbol (usually characters), the program just throws an exception and ends.

I fully understand why. The input line in the method is written as:
[CODE]
String userInput = user.getUserInput(" ");
double addNum = Double.parseDouble(userInput);
[/CODE]

If I am correct, the JVM is trying to parse some input (say "cat") to a double and can't do that. So it throws the exception:
Exception in thread "main" java.lang.NumberFormatException: For input string: "c
at"
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:12
22)
        at java.lang.Double.parseDouble(Double.java:510)
        at Arithmetic.Add(Arithmetic.java:5)
        at SimpleCalc.main(SimpleCalc.java:13)

All I am looking to do is create an error guard that will detect if the user inputs a String that is not numeric and will say "Your input was invalid."

I was thinking of using an IF statement to check if it was a integer/double but ran into two problems:

1. I don't exactly know how to do that...
2. The problem seems to occur when the parsing attempt is made on the input String. So the if statement would have to come before the parse. I'm not sure how to go about saying "All numeric strings"

I have checked the API but I am rather new to Java so I don't understand all of it... forgive me if I missed something.

Any help you can offer is appreciated. Thanks for your time!