My assignment is Write a static void method called printTrigTables that prints the sin, cos, and tan of angles
////between 0 and 360 in increments of 30 degrees. The first column should be the angle size,
//and the next three columns should be the sin, cos, and tan. Use either a while loop or a for
//loop. One problem you will encounter however is that the Math functions for sin, cos, and
//tan take radians, not degrees! So, you must convert your angle to radians first. Here is the
//formula for degree to radian conversion:
//radians = degrees x PI / 180.
public static double degConvert(double degrees){ // converts to degrees
double radians = degrees * (Math.PI/180);
return radians;
}
For the trig table, can anyone help me make a method, or several encapsulated methods that do the following:
Count from 0 to 360 by 30's, using a loop; convert those numbers into radians using the equation x*pi/180; take all of those values and put them into Math.sin(); print.
public static void printTrigTables () { double a1, a2, a3,a4,a5, a6, a7,a8,a9,a10,a11,a12;4 System.out.println ("degree, sin, cos, tan"); double degree; System.out.print("Angle 30 degree "); a1 = 30 * Math.PI/180; System.out.println ("cos(" + a1 + ") is " + Math.acos(a1)); System.out.println ("sin(" + a1 + ") is " + Math.asin(a1)); System.out.println("tan(" + a1 + ") is " + Math.atan(a1)); System.out.print("Angle 60 degree "); a2 = 60 * Math.PI/180; System.out.println("cos(" + a2 + ") is " + Math.acos(a2)) ; System.out.println("sin(" + a2 + ") is " + Math.asin(a2)); System.out.println("tan(" + a2 + ") is " + Math.atan(a2)); System.out.print("Angle 90 degree "); a3 = 90 * Math.PI/180; System.out.println("cos(" + a3 + ") is " + Math.acos(a3)) ; System.out.println("sin(" + a3 + ") is " + Math.asin(a3)); System.out.println("tan(" + a3 + ") is " + Math.atan(a3)); System.out.print("Angle 120 degree "); a4 = 120 * Math.PI/180; System.out.println("cos(" + a4 + ") is " + Math.acos(a4)); System.out.println("sin(" + a4 + ") is " + Math.asin(a4)); System.out.println("tan(" + a4 + ") is " + Math.atan(a4)); System.out.print("Angle 150 degree "); a5 = 150 * Math.PI/180; System.out.println("cos(" + a5 + ") is " + Math.acos(a5)); System.out.println("sin(" + a5 + ") is " + Math.asin(a5)); System.out.println("tan(" + a5 + ") is " + Math.atan(a5)); System.out.print("Angle 180 degree "); a6 = 180 * Math.PI/180; System.out.println("cos(" + a6 + ") is " + Math.acos(a6)); System.out.println("sin(" + a6 + ") is " + Math.asin(a6)); System.out.println("tan(" + a6 + ") is " + Math.atan(a6)); System.out.print("Angle 210 degree "); a7 = 210 * Math.PI/180; System.out.println("cos (" + a7 + ") is " + Math.acos(a7)); System.out.println("sin (" + a7 + ") is " + Math.asin(a7)); System.out.println("tan (" + a7 + ") is " + Math.atan(a7)); System.out.print("Angle 240 degree "); a8 = 240 * Math.PI/180; System.out.println("cos (" + a8 + ") is " + Math.acos(a8)); System.out.println("sin (" + a8 + ") is " + Math.asin(a8)); System.out.println("tan (" + a8 + ") is " + Math.atan(a8)); System.out.print("Angle 270 degree "); a9 = 270 * Math.PI/180; System.out.println("cos (" + a9 + ") is " + Math.acos(a9)); System.out.println("sin (" + a9 + ") is " + Math.asin(a9)); System.out.println("tan (" + a9 + ") is " + Math.atan(a9)); System.out.print("Angle 300 degree "); a10 = (300 * Math.PI)/180; System.out.println("cos (" + a10 + ") is " + Math.acos(a10)); System.out.println("sin (" + a10 + ") is " + Math.asin(a10)); System.out.println("tan (" + a10 + ") is " + Math.atan(a10)); System.out.print("Angle 330 degree "); a11 = (330 * Math.PI)/180; System.out.println("cos (" + a11 + ") is " + Math.acos(a11)); System.out.println("sin (" + a11 + ") is " + Math.asin(a11)); System.out.println("tan (" + a11 + ") is " + Math.atan(a11)); System.out.print("Angle 360 degree "); a12 = (360 * Math.PI)/180; System.out.println("cos (" + a12 + ") is " + Math.acos(a12)); System.out.println("sin (" + a12 + ") is " + Math.asin(a12)); System.out.println("tan (" + a12 + ") is " + Math.atan(a12)); } }
I don't know how to put a while or for loop into the program so the 1st column is the angle measure, the 2,3,and 4th columns are the trig values....Help me please!