Your task is to design, write, and run java algorithm to messier the body mass index (BMI) using an interface to allow the user to key in the values of the user weight in kilograms and value of the user height in centimeters to calculate the BMI and store it in an array. Your algorithm should generate different messages based on the BMI values:
· BMI = <18.5 (your weight is under weight)
· BMI = 18.5-24.9 (your weight is normal weight)
· BMI = 25-29.9 (your weight is over weight)
· BMI = 30 & above (your are obese)
أنا حاولت أحله وهذي طريقتي فالحل ياريت حد يساعدني ضروري :
package assig;
import javax.swing.JOptionPane;
public class BodyMass {
static double w,h;
public static void main(String[]args)
int[]w=new int;
int[]h=new int;
getWeight(w);
getHeight(h);
double getBMI=BMI(w,h);
}
public static void getWeight(Double[]w){
String s1 = JOptionPane.showInputDialog(" Excuse me ,,, " + " \n Please enter your weight :");
for(int r=0; r<w.length; r++){
double weight= Double.parseDouble(s1);
}
}
public static void getHeight(Double[]h){
String s2 = JOptionPane.showInputDialog(" Excuse me ,,, " + " \n Please enter your Height :");
for(int r=0; r<h.length; r++){
double height = Double.parseDouble(s2);
}
}
public static double getBMI(double[]BMI) {
for(int r=0; r<BMI.length; r++){
if(BMI[r]<=18.5){
JOptionPane.showMessageDialog( null,BMI+ " Your weight is under weight");
if(BMI[r]==18.5-24.9){
JOptionPane.showMessageDialog( null,BMI+ " Your weight is normal weight");
if(BMI[r]==25-29.9){
JOptionPane.showMessageDialog( null,BMI+ " Your weight is over weight");
if (BMI[r]>=30){
JOptionPane.showMessageDialog( null,BMI+ " Your are obese");
}
}
}
}
}
return w/(h*h)*1000;
}
}
شكرآ لكم