java tutorial - Java Math.cos() Method - tutorial java - java programming - learn java - java basics - java for beginners



Java numbers cos

Learn Java - Java tutorial - Java numbers cos - Java examples - Java programs

Description

The Math.cos () method - returns the cosine of the radian value.

Syntax

double cos(double d)
click below button to copy the code. By - java tutorial - team

Options

Detailed information about the parameters:

  • d is the double data type.

Return value

  • In Java, Math.cos () returns the cosine of the double value specified in radians.

Sample Code

public class Test { 

   public static void main(String args[]) {
      double degrees = 45.0;
      double radians = Math.toRadians(degrees);

      System.out.format("The value of pi is %.4f%n", Math.PI);
      System.out.format("The cosine of %.1f degrees is %.4f%n", degrees, Math.cos(radians));
   }
}
click below button to copy the code. By - java tutorial - team

Output

The value of pi is 3.1416
The cosine of 45.0 degrees is 0.7071

Table of basic cosine values:

 cos-table.png

Learn java - java tutorial - cos table - java examples - java programs


Related Searches to Java Math.cos() Method