A class and a test class are a great pairing. What a great habit to get into from the start! I'd guess this is for school work - if so your instructor is giving you some good ideas.
Here's a neat way to write tests so you don't have to examine the results closely by eye every time you run:
Now your tests just print a "." if they work, but give you a neat report if they fail.
One note, see how I had to turn the double result into a
string with ""+method(). That's a little kludgey and a bit hard to predict. You might prefer another assertEquals method that takes two doubles as arguments.
This style comes from a test package called
JUnit. It's maybe a bit advanced right now, but if you get into writing classes and tests (or tests BEFORE the classes!) you'll love it when you get to it.