⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exercise4_14.java

📁 Introduction to java programming 一书中所有编程练习部分的源码
💻 JAVA
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -