Aquí está mi código. Por alguna razón, mi IMC no se calculó correctamente. Cuando verifico el resultado en una calculadora para esto: (10/((10/100)^2)))
obtengo 1000, pero en mi programa, obtengo 5. No estoy seguro de lo que estoy haciendo mal. Aquí está mi código:Aumentando un número a una potencia en 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);
}
}
Este no es el operador que está buscando. – Malfist
@Malfist Mientras leo lo que escribiste puedo verte agitando la mano frente a su cara como un jedi –
@Malfist lol =) – stytown