这是我的代码。由于某些原因,我的BMI不能正确计算。当我在计算器上检查此输出时:(10/((10/100)^2)))得到1000,但在程序中得到5。我不确定自己做错了什么。这是我的代码:import javax.swing.*;public class BMI { public static void main(String args[]) { int height; int weight; String getweight; getweight = JOptionPane.showInputDialog(null, "Please enter your weight in Kilograms"); String getheight; getheight = JOptionPane.showInputDialog(null, "Please enter your height in Centimeters"); weight = Integer.parseInt(getweight); height = Integer.parseInt(getheight); double bmi; bmi = (weight/((height/100)^2)); JOptionPane.showMessageDialog(null, "Your BMI is: " + bmi); }}
添加回答
举报
0/150
提交
取消