This lab will give you some practice with Java's
Math class.
The Math class provides a number of commonly
used functions, including trigonometric and exponential
function, for your convenience.
In this lab we're going to use this function to plot
some functions.
Download Plot2D.java and save it in your csci/201 directory. Start up DrJava and load up your Plot2D.java file.
When you run the program it will display nine pictures that plot nine different and boring functions. You need to modify the program to plot more interesting functions.
The Java program you've loaded 157 lines long. However, you don't do anything to the first 110 lines of it. Go down to around line 110, where you will see a comment line like the following:
// *** START YOUR WORK HERE ***
Don't change anything before this comment line.
After this comment there are nine methods named
plot1 to plot9.
You'll be changing each of these methods.
As we said before, the Math class
provides many useful mathematical functions. To use a method in the
Math class, you type
Math.
followed by the name of the method
you want to use. If you can't remember the name of the method, you can still
type the Math. and
wait a few moments for NetBeans to bring up a list
of all of the methods in the Math class.
However, you'll be much more protective in this lab if you
first take a moment to study the
Java
documentation for the Math class.
Your assignment is to modify the
plotN methods to
implement the nine plots listed on the left below.
The Applet on the right should give you some idea of how
your finished program should work.
|
Once you've have your nine plots, show your work to the lab instructor.