import java.text.FieldPosition;
import java.text.NumberFormat;
public class MainClass {
public static void main(String[] args) {
NumberFormat myFormat = NumberFormat.getNumberInstance();
FieldPosition fp = new FieldPosition(NumberFormat.INTEGER_FIELD);
myFormat.setMaximumIntegerDigits(3);
myFormat.setMaximumFractionDigits(2);
myFormat.setMinimumFractionDigits(2);
System.out.println("Degrees Radians Grads");
for (double d = 0.0; d < 360.0; d++) {
String radianString = myFormat.format(Math.PI * d / 180.0, new StringBuffer(), fp)
.toString();
radianString = " " + radianString;
String gradString = myFormat.format(400 * d / 360, new StringBuffer(), fp).toString();
gradString = " " + gradString;
String degreeString = myFormat.format(d, new StringBuffer(), fp).toString();
degreeString = " " + degreeString;
System.out.println(degreeString + " " + radianString + " " + gradString);
}
}
}
|