Menu
Topics Index
...
`

Number Method Test3 - Java Example Program


Number Method Test3
class NumberMethodTest3
{
    public static void main(String arg[])
    {
        Double degree = 30.0;
            
        System.out.println("sin(30) : " + Math.sin(Math.toRadians(degree)));
        System.out.println("cos(30) : " + Math.cos(Math.toRadians(degree)));
        System.out.println("tan(30) : " + Math.tan(Math.toRadians(degree)));
        System.out.println("sec(30) : " + Math.asin(Math.toRadians(degree)));
        System.out.println("cosec(30) : " + Math.acos(Math.toRadians(degree)));
        System.out.println("cot(30) : " + Math.atan(Math.toRadians(degree)));
        System.out.println("Theta of rectangle co-ordinate : " + Math.atan2(45,30));    
    }
}
OUTPUT

sin(30) : 0.49999999999999994
cos(30) : 0.8660254037844387
tan(30) : 0.5773502691896257
sec(30) : 0.5510695830994463
cosec(30) : 1.0197267436954502
cot(30) : 0.48234790710102493
Theta of rectangle co-ordinate : 0.982793723247329

DESCRIPTION

In this program, Double value is converted into radians and then sin, cos, tan, asin, acos, atan and atan2 methods are used.

THINGS TO TRY
  • Change the degree value of 30.0 to 45.0, 60.0, 90.0 and see the output difference.

© meritcampus 2019

All Rights Reserved.

Open In App