Assignment 6: Demonstrate in class on or before April 18, 2005
Your previous lab asked you to complete the GraphPaper class as indicated.
In this assignment you will be
adding the following method to the GraphPaper class.
public void plotQuadratic(String s)
Using this method, you can use a GraphPaper object gp to plot a line by sending
a message like, for example, gp.plotQuadratic("a*x^2+b*x+2");. This will plot the quadratic a*x^2+b*x+2 on the GraphPaper object gp.
- You will have to use appropriate methods from the String class to parse the String s in the method. This parsing will allow you
to extract the coefficients for the quadratic
from the String s.
- Next, use a loop to evaluate the equation of the quadratic for different x values ranging from 0 to the width of the graph paper
(at intervals of 10) and draw a line between successive evaluation points. Make sure that the code inside the loop works correctly for at least two iterations
before trying it with many iterations
- Create a graph paper with width 300 and heigth 1000
- Test your code by plotting the quadratic 0.01*x^2+0.01*x+100 on the graph paper. Your graph will look similar to this.