# How to use trigonometric math methods in Java

7 views
edited Jun 10

```public class MyClass {
public static void main(String args[]) {
System.out.println("1) " + Math.toDegrees(Math.PI /2));
System.out.println("2) " + Math.toDegrees(Math.PI /4));

System.out.println("5) " + Math.sin(0));
System.out.println("7) " + Math.sin(Math.PI / 2));
System.out.println("8) " + Math.sin(Math.PI / 4));

System.out.println("9) " + Math.cos(0));
System.out.println("10) " + Math.cos(Math.PI / 2));
System.out.println("11) " + Math.cos(Math.PI / 4));

System.out.println("12) " + Math.asin(0.5));
System.out.println("13) " + Math.asin(1));

System.out.println("14) " + Math.acos(0.5));
System.out.println("15) " + Math.acos(1));

System.out.println("16) " + Math.atan(0.5));
System.out.println("17) " + Math.atan(1.0));
}
}

/*
run:

1) 90.0
2) 45.0
3) 0.5235987755982988
4) 0.6283185307179586
5) 0.0
6) 1.2246467991473532E-16
7) 1.0
8) 0.7071067811865475
9) 1.0
10) 6.123233995736766E-17
11) 0.7071067811865476
12) 0.5235987755982989
13) 1.5707963267948966
14) 1.0471975511965979
15) 0.0
16) 0.4636476090008061
17) 0.7853981633974483

*/```