這是我的代碼。由于某些原因,我的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
提交
取消