Write a MATLAB script that asks a group of up to 50 members
Solution
a)
x=[];
 y=[];
 prompt1 = \'Enter your height: \';
 prompt2 = \'Enter your weight: \';
 %loops from 1 to 50
 for i=1:50
 % prompt for height
 x(i)= input(prompt1);
 % checks for 0 value
 if x(i)==0
 break
 % breaks loop if true
 end
 % asks for weight
 y(i)=input(prompt2);
 if y(i)==0
 %checks for 0 value
 break
 % breaks the loop if 0
 end
 end% for loop ends
b)
x=[];
 y=[];
 bmi=[];
 prompt1 = \'Enter your height: \';
 prompt2 = \'Enter your weight: \';
 %loops from 1 to 50
 for i=1:50
% prompt for height
 x(i)= input(prompt1);
   
 % checks for 0 value
   
 if x(i)==0
 break
 % breaks loop if true
 end
   
 % asks for weight
 y(i)=input(prompt2);
   
 if y(i)==0
 %checks for 0 value
 break
 % breaks the loop if 0
 end
   
 % bmi check
 bmi(i)=y(i)/((x(i)/100)*(x(i)/100));
   
 if (bmi(i) >= 25) && (bmi(i) < 30)
 fprintf(\'your bmi is %d and your category is overweight \ \',bmi(i))
 elseif bmi(i) >= 30
 fprintf(\'your bmi is %d and your category is obese \ \',bmi(i))
 end
   
 end% for loop ends


