请问有什么功能^(尖)运算的Java服务?
当我尝试这个:
int a = 5^n;
Run Code Online (Sandbox Code Playgroud)
......它给了我:
对于n = 5,
对于n = 4 返回0 ,
对于n = 6 返回1 ,返回3
...所以我猜它不会执行取幂.但那又是什么呢?
这是我的代码.由于某种原因,我的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);
}
}
Run Code Online (Sandbox Code Playgroud)