toDegrees() and toRadians() in Java

toDegrees() is an inbuilt method in java that converts argument value to degrees.

Syntax:

 Math.toDegrees(double d)

Parameters:
The parameter is mandatory and has to be of a double data type. The passed parameter is thus converted to degrees.

Returns
It returns a value of data-type. The passed argument gets converted to degrees and is returned.

Code#1: Program explaining the implementation of toDegrees()

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program for implementation of
// toDegrees() method
import java.util.*;
class GFG {
  
    // Driver Code
    public static void main(String args[])
    {
        double x = 12.0;
        double y = 19.0;
  
        // conversion of number to degrees using
        // inbuilt function
        double xinDegrees = Math.toDegrees(x);
        double yinDegrees = Math.toDegrees(y);
  
        // Prints the number in degrees
        System.out.println(xinDegrees);
        System.out.println(yinDegrees);
    }
}

chevron_right


Output:

687.5493541569879
1088.619810748564

Output:

687.5493541569879
1088.619810748564

toRadians() is an inbuilt method in java that converts argument value to radian.

Syntax:

 Math.toRadians(double d)

Parameters:
The parameter is mandatory and has to be of a double data type. The passed parameter is thus converted to radians.

Returns
It returns a value of data-type. The passed argument gets converted to radians and is returned.

Code#2: Program explaining the implementation of toRadians()

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program for implementation of
// toRadians() method
import java.util.*;
class GFG {
  
    // Driver Code
    public static void main(String args[])
    {
        double x = 12.0;
        double y = 19.0;
  
        // conversion of number to Radians using
        // inbuilt function
        double xinRadians = Math.toRadians(x);
        double yinRadians = Math.toRadians(y);
  
        // Prints the number in Radians
        System.out.println(xinRadians);
        System.out.println(yinRadians);
    }
}

chevron_right


Output:

0.20943951023931953
0.33161255787892263


My Personal Notes arrow_drop_up

Striver(underscore)79 at Codechef and codeforces D

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.