wallcalculations1.java

来自「Java the UML Way 书中所有源码」· Java 代码 · 共 20 行

JAVA
20
字号
/*
 * WallCalculations1.java   E.L. 2001-08-09
 */

class WallCalculations1 {
  public static void main(String[] args) {
    double length = -2.5;
    double height = 3;
    if (length > 0 && height > 0) {  // if length > 0 and height > 0
      double area = length * height;
      System.out.println("The area of the wall is " + area + " square meters.");
    } else {                        // ...else....
      System.out.println("The length and/or the height has a non-positive value.");
    }
  }
}

/* Example Run:
The length and/or the height has a non-positive value.
*/

⌨️ 快捷键说明

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