import java.lang.Math;
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int n, j;
double x1, y1, x2, y2, theta;
Scanner s = new Scanner(System.in);
System.out.println("Please Enter n =");
n = s.nextInt();
System.out.println("Please Enter theta =");
theta = s.nextFloat();
x1 = Math.cos(theta);
y1 = Math.sin(theta);
x2 = x1;
y2 = y1;
j = 1;
while(j <= n) {
System.out.printf("(cos theta + i sin theta)%d = %8.3f + i%8.3f¥n", j, x1, y1);
System.out.printf("cos %d theta + i sin %d theta = %8.3f + i %8.3f¥n", j, j,
Math.cos(j * theta), Math.sin(j * theta));
x1 = x1 * x2 - y1 * y2;
y1 = x1 * y2 + x2 * y1;
j = j + 1;
}
}
}
32
繰り返し実行される
部分
条件式