0% found this document useful (0 votes)
4 views3 pages

Assignment 1

Uploaded by

valentoninelli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Assignment 1

Uploaded by

valentoninelli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ISM3230 Individual Assignment 1 – Working with Variables and Expressions

Basal metabolic rate (BMR) is the minimal rate of energy expenditure per unit time by warm-blooded
organisms at rest. This can also be expressed as the amount of energy one needs to consume per day to
maintain the same body weight.

Several mathematical models exist that predict with varying levels of accuracy the BMR for people based
on the person's weight, height, age and gender. One such model is the Revised Harris-Benedict equation
that gives the amount of Calories needed per day for a man:

BMR = 88.362 + 13.397 * weight + 4.799 * height -5.677 * age

where

weight is in kilograms

height is in centimeters

age is in years

The amount of energy contained in food is also expressed in Calories. A medium apple contains about 95
Cal, a single strawberry has on average 4 Cal.

Requirements:

Create a program that asks the user to enter the weight, height and age of a person and then calculates
the BMR for a male. In addition, it calculates how many whole apples and whole strawberries must be
consumed per day to sustain the calculated BMR. The height and weight is provided by the user in
imperial units, you must convert them to metric units in your program. Use named constants for
conversion factors between metric and imperial, as well as for the amount of Calories for the different
fruit.

1. Prompt the user to enter three numbers: weight in pounds, height in inches, and age in years.
Convert the user input to numeric variables. Weight and height should be floats, age should be
an integer.
2. Convert the weight and height to kilograms and centimeters, respectively, and store them to
new numeric variables. Use constants for the conversion factors (constants are variables with
the naming convention of capitalized names with an underscore between words). There are 2.54
centimeters per inch, and 2.2 pounds per kilogram.
3. Calculate the BMR given the formula above with floating point math and save it in a variable.
4. To report the BMR to the user and to calculate the amount of fruit required, use the BMR
truncated to whole numbers. In other words, use integer math. Convert the float value to an
integer value (by using a conversion function). Store this value to a new variable and use this
integer BMR for the rest of the code.
5. Calculate the number of whole apples necessary to sustain the BMR. Use a named constant for
the number of Calories per apple when calculating the number of apples.
6. Calculate the number of whole strawberries necessary to sustain the remainder of the BMR
(after apples are taken into account). Use a named constant for the number of Calories per
strawberry when calculating the number of strawberries.
7. Calculate the remainder of the BMR after the strawberries are taken into account.
8. Print to screen the following information:
o the weight in pounds and kilograms
o the height in inches and centimeters
o the age in years
o the BMR in whole Calories
o the number of whole apples
o the number of whole strawberries
o the remainder of the BMR in whole Calories
Hint: Pay attention to the type of the numeric variables (int vs float).
9. Check your output carefully to ensure that it matches the sample output. For the purposes of
this lab, “matching” means that all spacing, wording, and punctuation in your output should
match the sample output exactly.

SAMPLE OUTPUT

You might also like