cos() Method in java

Java Programming Language / Number Class in java

848

Program:

 public class WrappercosMethod {

   public static void main(String args[]) {
         double degrees = 60.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));
      }
}

/*

Returns the cosine of the specified double value.

*/

Output:

The value of pi is 3.1416
The cosine of 60.0 degrees is 0.5000
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.