toRadians() and toDegrees() Sample program in Java

By: Ivan Lim Viewed: 153305 times  Printer Friendly Format    


The toRadians() method converts degrees to radians. toDegrees() converts radians to degrees. Here is a program that demonstrates toRadians() and toDegrees():

// Demonstrate toDegrees() and toRadians().
class Angles {
public static void main(String args[]) {
double theta = 120.0;
System.out.println(theta + " degrees is " +
Math.toRadians(theta) + " radians.");
theta = 1.312;
System.out.println(theta + " radians is " +
Math.toDegrees(theta) + " degrees.");
}
}

The output is shown here.

120.0 degrees is 2.0943951023931953 radians.
1.312 radians is 75.17206272116401 degrees.



Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial