在Java中将数字提高到幂
2022-08-31 10:42:07
这是我的代码。由于某种原因,我的BMI计算不正确。当我在计算器上检查输出时:我得到1000,但在我的程序中,我得到5。我不确定我做错了什么。这是我的代码:(10/((10/100)^2)))
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);
}
}