Math cos Example

Java Math.cos example code. Learn how to use Math.cos function of the Math class.


With this example we will describe you how to use Math.cos method to find the cos value of a given number or double value.This method returns the trignometric cos value of angles in radians

Syntax:- cos(double a)

Here is the code:-
01 /**
02  * @(#) CosMath.java 
03  * CosMath class demonstrates the working of Cos() method of
04  * String class of lang package
05  @version 17-May-2008
06  @author Rose India Team
07  */
08 
09 public class CosMath {
10   public static void main(String args[]) {
11 
12     // Method cos() takes arguments in radians and returns the corresponding
13     // trignometric angle values
14     // Method will return only double value
15     double angle = Math.sin(Math.toRadians(30));
16 
17     System.out.println("Method generates sin Thirty(30) degree and cos zero(0) degree value respectively");
18     System.out.println(angle);
19     System.out.println(Math.cos(Math.toRadians(0)));
20 
21   }
22 
23 }

Output of the program:-
Method generates sin Thirty(30) degree and cos zero(0) degree value respectively
0.49999999999999994
1.0

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US