Question: Good afternoon, I am having trouble with a python assignment. This is the criteria. Family Fitness Center has hired you to create a program that
Good afternoon, I am having trouble with a python assignment. This is the criteria.
Family Fitness Center has hired you to create a program that calculates the body mass index (BMI) for it's clients and lets them know their status based upon it.
A client's BMI is calculated with the following formula: BMI = weight x 703 / height2
The program should allow the client to enter their gender (M or m for Male or F or f for Female), weight (in pounds as a whole number), and height (in inches as a whole number).The program should calculate and display the client's BMI and determine and display whether the client's status is overweight, underweight, or optimal weight. The input, function calls, and output should be placed in the main function. The determination of status is based upon the following criteria:
A male is considered to be at Optimal Weight if his BMI is between 18.5 and 25.
If his BMI is less than 18.5, he is considered to be Underweight.
Finally, if his BMI is greater than 25, he is considered to be Overweight.
A female is considered to be at Optimal Weight if her BMI is between 17 and 22.
If her BMI is less than 17, she is considered to be Underweight.
Finally, if her BMI is greater than 22, she is considered to be Overweight.
The program should allow the user to enter as many clients as desired by prompting the user if they want to continue
I have written the following code but I'm really not sure what I'm doing wrong? When I run my program It does not throw any errors but does not work either.
def main(): subjectGender = input("Enter gender M/F: ") subjectWeight = float(input("Enter your weight in pounds: ")) while subjectWeight < 0: print("Invalid entry. Weight must be greater than zero.") float(input("Enter your weight in pounds: ")) subjectHeight = float(input("Enter your height in inches: ")) while subjectHeight < 0: print("Invalid entry. Height must be greater than zero.") float(input("Enter your height in inches: ")) rerun_main = input("Do you want to continue? Enter y/n: ") if rerun_main == "Y" or rerun_main == "y": main()
return subjectGender, subjectWeight, subjectHeight
def calc_bmi(subjectWeight, subjectHeight): subjectBodyMassIndex = (subjectWeight * 703) / (subjectHeight ** 2) return subjectBodyMassIndex
def determine_status(subjectBodyMassIndex, subjectGender): while subjectGender == "M" or subjectGender == "m": if subjectBodyMassIndex < 18.5: print("BMI: " + str(subjectBodyMassIndex, ".2f") + " : Underweight.") elif subjectBodyMassIndex < 26: print("BMI: " + str(subjectBodyMassIndex, ".2f") + " : Optimal weight.") elif subjectBodyMassIndex > 25: print("BMI: " + str(subjectBodyMassIndex, ".2f") + " : Overweight.") break while subjectGender == "F": if subjectBodyMassIndex < 17: print("BMI: " + str(subjectBodyMassIndex, ".2f") + " : Underweight.") elif subjectBodyMassIndex < 22: print("BMI: " + str(subjectBodyMassIndex, ".2f") + " : Optimal weight.") elif subjectBodyMassIndex > 22: print("BMI: " + str(subjectBodyMassIndex, ".2f") + " : Overweight.") break
main() calc_bmi(subjectWeight, subjectHeight) determine_status(subjectBodyMassIndex, subjectGender)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
