Problem Description/Purpose:

  • Write a program that allows the user to enter information about a person and the total number of calories they plan to eat that day. The output would be total number of calories they can intake without gaining weight.
  • The user should be asked to input:
    • weight in pounds, height in inches,
    • age in years,
    • whether they are male (M) or female (F) and
    • ask them to choose between the following activity levles: A. Sedentary, B, Somewhat active (exercise occasionally), C. Active (exercise 3-4 days per week), and D. Highly active (exercise every day).
  • If the user enters an invalid gender, then the program should indicate "invalid gender entry" and end the program. (See example output: "Invalid Make/Female input" below)
  • If the user enters a value other than activity level, the program should continue with the base calories. (See example output: "Execution with an activity level that does not exist. It still calculated the calories based on the original BMR formula" below)
  • The program should calculate how many calories should be consumed to mantain one's weight based on the input of age, weight, gender, and activity level.

The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do not exercise. This is called your basal metabolic rate or BMR.

  • The calories needed for a female to maintain her weight is:
    • BMR = 655 + (4.3 * weight in pounds) + (4.7 * height in inches) - (4.7 * age in years)
  • The calories needed for a male to maintain his weight is
    • BMR = 66 + (6.3 * weight in pounds) + (12.9 * height in inches) - (6.8 * age in years)
  • Activity level impacts the BMR as follows:
    • Sedentary activity increases the calculated BMR by 20 percent.
    • Somewhat active increases the calculated BMR by 30 percent.
    • Active increases the calculated BMR by 40 percent.
    • Highly active increases the calculated BMR by 50 percent.

Requirements:

1. Set appropriate variables for all data. Use meaningful names.

2. ActivityLevel variable must be a char and should be read as a char.

3. The BMR calculation result should be placed into one double variable. You should not have a separate BMR_Male and BMR_Female variables.

4. You should be using conditional statements including (if or if-else or if-elseif-...-else) statements and switch statements. It is not necessary to have nested conditions.

5. Feel free to create AS MANY variables as you need.

6. YOU MAY USE printf to format your output, but you are NOT required to. It is okay to use println() and not format the decimal output.

Samples of Output

Valid output:

----------Please answer the questions below.----------
What is the age in years?
25
What is the total height in inches?
60
What is the weight in pounds?
150
The calorie calculation varies for a Male versus a Female.
Enter 'M' for male calculation or 'F' for female calculation.
M
Categorize your activity level as one of the following:
A. Sedentary
B. Somewhat active (exercise occasionally)
C. Active (exercise 3-4 days per week)
D. Highly active (exercise every day)
Enter A, B, C, or D.
A

----------Thank you for answering the questions.----------
Age: 25
Height: 60.0
Weight: 150.0
Gender: Male
Activity Level: Sedentary

A Male with these measurements should eat 1938.0 per day to maintain the same weight.
----------Please answer the questions below.----------
What is the age in years?
25
What is the total height in inches?
60
What is the weight in pounds?
150
The calorie calculation varies for a Male versus a Female.
Enter 'M' for male calculation or 'F' for female calculation.
M
Categorize your activity level as one of the following:
A. Sedentary
B. Somewhat active (exercise occasionally)
C. Active (exercise 3-4 days per week)
D. Highly active (exercise every day)
Enter A, B, C, or D.
F

----------Thank you for answering the questions.----------
Age: 25
Height: 60.0
Weight: 150.0
Gender: Male
Activity Level: not identified

A Male with these measurements should eat 1615.0 per day to maintain the same weight.

Invalid Male/Female input:

----------Please answer the questions below.----------
What is the age in years?
25
What is the total height in inches?
60
What is the weight in pounds?
150
The calorie calculation varies for a Male versus a Female.
Enter 'M' for male calculation or 'F' for female calculation.
<
Categorize your activity level as one of the following:
A. Sedentary
B. Somewhat active (exercise occasionally)
C. Active (exercise 3-4 days per week)
D. Highly active (exercise every day)
Enter A, B, C, or D.
A
Invalid entry for gender.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.