library.java

来自「Java 入门书的源码」· Java 代码 · 共 27 行

JAVA
27
字号
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.

/* Uses methods from the Math class
 */

import iopack.Io;
public class Library {
  public static void main(String [] args)  {
     System.out.println("Two cubed is " + Math.pow(2.0,3.0));
     System.out.println("Three squared is " + Math.pow(3.0,2.0));
     System.out.println("The square root of two is " + Math.sqrt(2.0));
     System.out.println("The square root of 16 is " + Math.sqrt(16.0));
     System.out.println("The max of 2.56 and 7.91/3.1 is " + Math.max(2.65,7.91/3.1));
     System.out.println("The min of -9 and -11 is " + Math.min(-9,-11));
     System.out.println("The absolute value of -32.47 is " + Math.abs(-32.47));
     System.out.println("The floor of 25.194 is " + Math.floor(25.194));
     System.out.println("The ceiling of 25.194 is " + Math.ceil(25.194));
     System.out.println("Pi is " + Math.PI);
     System.out.print("Pi, to six decimal places, is ");
     Io.println(Math.PI,6);
     System.out.println("The base of natural logarithms, e, is " + Math.E);
     Io.readString("Press any key to exit");   // Added for IDE use
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?