Solutions 2 7 profit salePrice purchasePrice output profit output SALEPROMPT

# Solutions 2 7 profit saleprice purchaseprice output

• Homework Help
• 26
• 95% (43) 41 out of 43 people found this document helpful

This preview shows page 7 - 12 out of 26 pages.

6.a. Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI). BMI is a statistical measure that compares a person’s weight and height. The program uses three modules. The first prompts a userfor and accepts a user’s height in inches. The second module accepts the user’s weight in pounds and converts the user’s height to meters and weight to kilograms. Then, it calculates BMI as weight in kilograms times height in meters squared, and displays the results. There are 2.54 centimeters in an inch, 100 centimeters in a meter,453.59 grams in a pound, and 1,000 grams in a kilogram. Use named constants whenever you think they are appropriate. The last module displays the message End of job.
Programming Logic and Design, 7e Solutions 2-8 Pseudocode: start Declarations num heightInches num weightPounds num heightMeters num weightKilos num bmi num CENT_IN_INCH = 2.54 num CENT_IN_METER = 100 num GRAM_IN_POUND = 453.59 num GRAM_IN_KILO = 1000 string HEIGHT_PROMPT = “Enter the user’s height in inches: ” string WEIGHT_PROMPT = “Enter the user’s weight in pounds: ” string END_LINE = “End of job” housekeeping() detail() endOfJob() stop housekeeping()
b. Revise the BMI-determining program to execute continuously until the user enters 0 for the height in inches. :
Programming Logic and Design, 7e Solutions 2-10 Pseudocode: start Declarations num heightInches num weightPounds num heightMeters num weightKilos num bmi num CENT_IN_INCH = 2.54 num CENT_IN_METER = 100 num GRAM_IN_POUND = 453.59 num GRAM_IN_KILO = 1000 string HEIGHT_PROMPT = “Enter the user’s height in inches: ” string WEIGHT_PROMPT = “Enter the user’s weight in pounds: ” string END_LINE = “End of job”
Programming Logic and Design, 7e