To graph a function using Turtle, you just have to loop through the range of x values. In this case -320<x<320 is the range. Incrementing by 1 will be overkill so you can increment by 5 or 10 if you want. For each x calculate the y of the function and then have the turtle go to that position.
Plot the following functions each in a different color.
f(x)=200sin(xπ/160)
A parabola with a vertex bottom center (0,-240) and it passes through the top-right corner (320,240) and top-left corner (-320,240) of the screen.
A cosine function with a user specified amplitude and number of periods on the screen. (Use Scanner. Play with the numbers on the first function and you should be able to figure out how to make this one work.)
Plotting f(x)=200sin(xπ/160) in red...
Plotting parabola in blue...
Enter the following values.
Amplitude: 100
Number of Periods: 3
Plotting the cosine function in green...
Here is an example that will plot a half circle. f(x)=Math.sqrt(100*100-x*x)
Turtle bob= new Turtle();
for(int x = -120; x < 120; x+=10)
{
y=Math.sqrt(100*100-x*x);
bob.goTo(x,y);
}
Hint: Read this if you need help getting the parabola formula.