wallcalculations2.java

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

JAVA
21
字号
/*
 * WallCalculations2.java   E.L. 2001-06-16
 */
import javax.swing.JOptionPane;
class WallCalculations2 {
  public static void main(String[] args) {
    String lengthInput = JOptionPane.showInputDialog("The length of the wall (meters): ");
    String heightInput = JOptionPane.showInputDialog("The height of the wall (meters): ");
    double length = Double.parseDouble(lengthInput);
    double height = Double.parseDouble(heightInput);
    double area = length * height;
    JOptionPane.showMessageDialog(null, 
                "The area of the wall is " + area + " square meters.");
    System.exit(0);
  }
}
/* Example Run:
Length: 5.8 m
Height: 2.4 m
The area of the wall is 13.92 square meters.
*/

⌨️ 快捷键说明

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