📄 exercise2_2.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 + -