I am planning to make a BMI calculation in which this program will prompt the user to enter new inputs repetitively as long as both inputs are positive. In this case, my input is weight and height. I have applied while loop in my code. However, when I enter two positive inputs and after the BMI calculation has been performed, the process ends and exits. May I know which line did I code wrongly?
while 1
if (Weight > 0 && Height > 0)
Weight = input('Please Enter Your Weight In kg: ');
Height = input('Please Enter Your Height In m : ');
BMI = Weight/(Height^2);
if (BMI<=18.5)
disp(['Health condition: THIN. Your BMI is ', num2str(BMI)]);
elseif (BMI>=18.6) && (BMI<=24.9)
disp(['Health condition: HEALTHY. Your BMI is ', num2str(BMI)]);
elseif (BMI<=25) && (BMI<=29.9)
disp(['Health condition: OVERWEIGHT. Your BMI is ', num2str(BMI)]);
else (BMI>=30)
disp(['Health condition: OBESE. Your BMI is ', num2str(BMI)]);
end
break
end
end
Thank you.