Ecco il mio codice. Per qualche ragione il mio BMI non è calcolato correttamente. Quando controllo l'output su una calcolatrice per questo: (10/((10/100)^2)))
Ottengo 1000, ma nel mio programma ottengo 5. Non sono sicuro di cosa sto facendo male. Qui è il mio codice:Aumentare un numero a una potenza in 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);
}
}
Questo non è l'operatore che stai cercando. – Malfist
@Malfist Mentre leggo quello che hai scritto posso vederti agitare la mano davanti alla sua faccia come un jedi –
@Malfist lol =) – stytown