首页 > 代码库 > 计算一个圆柱体的体积

计算一个圆柱体的体积

import javax.swing.JOptionPane;public class ComputeVolume {    public static void main(String[] args){        final double PI = 3.14;        double volume;        String inputRadius = JOptionPane.showInputDialog(null,"plz enter a radius:",                "Input Dialog Demo",JOptionPane.QUESTION_MESSAGE);        String inputHeight = JOptionPane.showInputDialog(null,"plz enter a height:",                "Input Dialog Demo",JOptionPane.QUESTION_MESSAGE);        double radius = Double.parseDouble(inputRadius);        double height = Double.parseDouble(inputHeight);        volume = (int)(radius * radius * PI * height);        JOptionPane.showMessageDialog(null, "the Volume is :" + volume);    }}