Answer:
The program in Java is as follows:
import java.lang.Math;
public class Trig{
public static void main(String args[]){
for(double angle = 0; angle <= Math.PI; angle += Math.PI / 2){
double cosX = Math.round(Math.cos(angle)*100.0)/100.0;
double sinX = Math.round(Math.sin(angle)*100.0)/100.0;
System.out.println((Math.round(angle*100)/100.0)+" --> "+cosX +" --> "+ sinX);
}}}
Explanation:
This line imports the math library into the program
import java.lang.Math;
This line defines a class
public class Trig{
This line defines the main method
public static void main(String args[]){
This line is an iteration that iterates from 0, through Math.PI using Math.PI/2 as an interval
for(double angle = 0; angle <= Math.PI; angle += Math.PI / 2){
This calculates the cosine of the angle (in radians)
double cosX = Math.round(Math.cos(angle)*100.0)/100.0;
This calculates the sine of the angle (in radians)
double sinX = Math.round(Math.sin(angle)*100.0)/100.0;
This prints the angle in radians, the cosine and the sine of the angle
System.out.println((Math.round(angle*100)/100.0)+" --> "+cosX +" --> "+ sinX);
}}}