exercise4_14.java
来自「Introduction to java programming 一书中所有编程」· Java 代码 · 共 18 行
JAVA
18 行
// Exercise4_14.java: Display sin and cos table
public class Exercise4_14 {
public static void main(String[] args) {
System.out.println("Degree\tSin\t\tCos");
for (int degree = 0; degree <= 360; degree += 10) {
System.out.println(degree + "\t" +
format(Math.sin(degree * Math.PI / 180), 4)
+ "\t\t" + format(Math.cos(degree * Math.PI / 180), 4));
}
}
public static double format(double d, int position) {
return Math.round(d * Math.pow(10, position)) / Math.pow(10, position);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?