Unit Converter from Radian to Degree and back - Java Algorithm

Java examples for Algorithm:Geometry

Description

Unit Converter from Radian to Degree and back

Demo Code


public class Main {

  public static void main(String[] args) {
     double number = 123;
     System.out.printf("%.6f rad\r\n", toRadins(number));
     System.out.printf("%.6f deg\r\n", toDegrees(number));
  }//end of main//from  w ww .j a  v  a2s . c o m
  
  private static double toRadins(double degrees){
    double radians = (degrees/180)*Math.PI;
    return radians;
  }
  
  private static double toDegrees(double radians){
    double degrees = (radians*180)/Math.PI;
    return degrees;
  }
}//end of class

Related Tutorials