readinteger.java

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

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

/*    Uses readInt method to read integer values 
 *    from the keyboard.  Outputs the sum of the
 *    three inputs.
*/

import iopack.Io;
public class ReadInteger {
  public static void main(String [ ] args) {
    int x, y, z, result;
    x = Io.readInt("Enter the first number");
    y = Io.readInt("Enter the second number");
    z = Io.readInt("Enter the third number");
    result = x + y + z;
    System.out.println("The result is " + result);
    Io.readString("Press any key to exit");   // Added for IDE use
  }
}   

⌨️ 快捷键说明

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