I'm using the turtle api to finish [this assignment] (http://sites.asmsa.org/java-turtle/exer/5-function-graphing). I'm stuck on graphing the cosine function displaying a user-specified number of periods. The for loop is what I'm using to generate the y-coordinates of the graph for intervals of x values. Wouldn't y = (x/2pi*period)? This is displaying too many periods though. (also amp is for amplitude, and I named my turtle don for donatello)
Scanner sc = new Scanner(System.in);
System.out.println("Enter the following values.");
System.out.print("Amplitude: ");
int amp = sc.nextInt();
System.out.print("Number of Periods:");
int per = sc.nextInt();
don.setPosition(-320, amp * Math.cos( -320 / (4 * Math.PI * per)));
don.down();
for(int x = -320; x < 320; x+=5) {
double y = amp * Math.cos(x/(2 * Math.PI * per));
don.setPosition(x, y);
}