ここに私のコードです。何らかの理由で私のBMIが正しく計算されません。 電卓の出力をチェックすると、(10/((10/100)^2)))
は1000になりますが、私のプログラムでは5になります。間違っていることはわかりません。私のコードは以下の通りです:Javaで数を電源にする
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);
}
}
これはあなたが探している演算子ではありません。 – Malfist
@マフリストあなたが書いたことを読んでいるうちに、ジェダイのように顔を手で振っているのを見ることができます –
@マフリストlol =) – stytown