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

📄 exercise2_2.java

📁 java程序设计导论(daniel liang著) 所有偶数课后习题答案
💻 JAVA
字号:
import javax.swing.JOptionPane;

public class Exercise2_2  {
  public static void main(String[] args) {
    // Enter radius of the cylinder
    String radiusString = JOptionPane.showInputDialog(null,
      "Enter radius of the cylinder",
      "Exercise2_2 Input", JOptionPane.QUESTION_MESSAGE);
    
    // Convert string to double
    double radius = Double.parseDouble(radiusString);
    
    // Enter length of the cylinder
    String lengthString = JOptionPane.showInputDialog(null,
      "Enter length of the cylinder",
      "Exercise2_2 Input", JOptionPane.QUESTION_MESSAGE);
    
    // Convert string to double
    double length = Double.parseDouble(lengthString);

    double volume = radius * radius * 3.14159 *length;
    
    System.out.println("The volume of the cylinder is " + volume);

    System.exit(0);
  }
}

⌨️ 快捷键说明

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