Print the following table to display the sin value and cos value of degrees from
ID: 3630211 • Letter: P
Question
Print the following table to display the sin value and cos value of degrees from 0 to 360 with increments of 10 degrees. Round the value to keep four digits after the decimal point.Degree Sin Cos
0 0.0000 1.0000
10 0.1736 0.9848
...
350 -0.1736 0.9848
360 0.0000 1.0000
(I don't understand how to properly space the table and the code returns errors. Here is my code)
public class Trig {
public static void main(String[] args) {
System.out.println("Degree Sin Cos");
for (int degree = 0; degree <= 360; degree += 10)
double radians = Math.toRadians(degree);
double sin = Math.sin(radians);
double cos = Math.cos(radians);
System.out.printf("%d%5.4f%5.4f ", degree, sin, cos);
}
}
Explanation / Answer
please rate - thanks
public class Trig {
public static void main(String[] args) {
System.out.println("Degree Sin Cos");
for (int degree = 0; degree <= 360; degree += 10)
{
double radians = Math.toRadians(degree);
double sin = Math.sin(radians);
double cos = Math.cos(radians);
System.out.printf(" %4d%10.4f%10.4f ", degree, sin, cos);
}
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.