daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function BMI()
  2. % This program calculates the BMI of a person. It allow for the program to
  3. % be used worldwide and takes account for the Imperial and Metric systems
  4. % for easy use.
  5. clc;
  6. clear;
  7.  
  8. % Displays the information to the user about the systems which can be used.
  9. disp('                  --- BMI Calculator --- ');
  10. disp('Please choose the measurement system you would like to use:');
  11. disp('      1. Kilograms/Centimeters');
  12. disp('      2. Pounds/Inches');
  13. disp('      3. Pounds/Feet');
  14. disp('      4. Stone/Inches');
  15. optn = input('Please choose which system you would like to use. [1/2/3/4]: ');
  16.  
  17. % Checks to see which system the user has chosen and asks for the variables
  18. % accordingly.
  19. if optn == 1
  20.     disp('Please input the your Weight, and Height');
  21.     w = input('Your Weight(Kg) is? ');
  22.     h = input('Your Height(cm) is? ');
  23.     h1 = h / 100;
  24.     BMI = round(w / h1^2);
  25.     pause(1)
  26.        
  27. elseif optn == 2
  28.     disp('Please input the your Weight, and Height');
  29.     w = input('Your Weight(lbs) is? ');
  30.     h = input('Your Height(in.) is? ');
  31.     BMI = round((w / (h^2)*703));
  32.     pause(1)
  33.        
  34. elseif optn == 3
  35.     disp('Please input the your Weight, and Height');
  36.     w = input('Your Weight(lbs) is? ');
  37.     h = input('Your Height(ft) is? ');
  38.     BMI = round((w / (h^2)*4.88));
  39.     pause(1)
  40.        
  41. elseif optn == 4
  42.     disp('Please input the your Weight, and Height');
  43.     w = input('Your Weight(st) is? ');
  44.     h = input('Your Height(in.) is? ');
  45.     BMI = round((w / (h^2)*9840));
  46.     pause(1)
  47.        
  48. else
  49.     disp('Please choose a valid option.')
  50.     pause(2.5)
  51.     BMI();
  52. end
  53.  
  54. % Displays the users BMI
  55. disp(['Your BMI is: ', num2str(BMI)])
  56.  
  57. % Displays a message to the user about where they fall on the BMI scale and
  58. % tells the user what their BMI means.
  59. if BMI <= 18
  60.     disp('You are very underweight and possibly malnourished.')
  61. elseif BMI <20
  62.     disp('You are underweight and could afford to gain a little weight.')
  63. elseif BMI <=25
  64.     disp('You have a healthy weight range for young and middle-aged adults.')
  65. elseif BMI <=30
  66.     disp('You are overweight')
  67. elseif BMI > 30
  68.     disp('You are obese')
  69. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top