Hi,
this code works:
clear all
clear clf
clear clc
user_dia_prcnt = 0;
user_age = input('Type your age: ');
user_gender = input('Type M or F: ','s');
%Gathers BMI
user_weight = input('Type your weight (lbs): ');
user_height = input('Type your height (in): ');
user_bmi = (user_weight*703)/user_height^2;
%add fprintf to final summary
fprintf('Your Body Mass Index is %f\n', user_bmi);
if strcmp(user_gender, 'M')
if(user_age <= 45)
if(user_bmi >= 35)
user_dia_prcnt = user_dia_prcnt + 66.1;
elseif(user_bmi <= 25)
user_dia_prcnt = user_dia_prcnt + 51.8;
elseif(user_bmi <= 30)
user_dia_prcnt = user_dia_prcnt + 25.5;
elseif(user_bmi <= 35)
user_dia_prcnt = user_dia_prcnt + 16.9;
else
user_dia_prcnt = user_dia_prcnt + 6.2;
end
end
end
fprintf('Percentage is: %f \n ',user_dia_prcnt);
You don't specify what happens, if the user is female. And I think other cases are missing as well.