简单计算三个整数的积

//calculate the product of three integers


public class Product {


public static void main(String[] args) {

int x;
int y;
int z;
int result;

String xval;
String yval;
String zval;

//提示用户输入第一个整数,读取用户输入的第一个数
xval = JOptionPane.showInputDialog( "Enter first integer:" );

//提示用户输入第二个整数,读取用户输入的第二个数
yval = JOptionPane.showInputDialog( "Enter second integer:" );

//提示用户输入第三个整数,读取用户输入的第三个数
zval = JOptionPane.showInputDialog( "Enter third integer:");

//将输入的数的类型由String类型转换为int类型
x = Integer.parseInt(xval);
y = Integer.parseInt(yval);
z = Integer.parseInt(zval);

result = x * y * z;

//输出结果
JOptionPane.showMessageDialog(null, "The product is "+ result);

System.exit(0);
}


}

运行结果:





猜你喜欢

转载自blog.csdn.net/fzbeiqing/article/details/79263140