CS U216 -- Algorithms and Data Structures for Engineers

Assignment 1

Due 11 May, 2005

Write a C++ program that prompts for and reads a patient's name, weight in pounds, and height in feet and inches, and then calculates and displays the patient's name, mass in kilograms, height in meters, and Body Mass Index (BMI). For example:

What is the patient's name? Arnolda
What is the patient's weight in pounds? 100
What is the patient's height in feet and inches? 5 1

Arnolda's weight is about 45.36 kilograms.
Arnolda's height is about 1.5494 meters.
Arnolda's BMI is approximately 18.89495851015352.

May I close this console window? y
In the example above, the italic or slanted text represents input typed by a user of the program. The rest of the text represents the prompts and other output of the program.

Requirements

Background Information

A person's Body Mass Index (BMI) is defined to be the person's mass m in kilograms divided by the square of the person's height h in meters. In C++ this calculation would be written as m / (h * h).

There are still a few corners of the world where the old English system of measures remains in use. In the United States, the Omnibus Trade and Competitiveness Act of 1988 declared the International System of Units (SI) to be the preferred system for trade and commerce, but many citizens continue to think in terms of pounds and inches. This program accomodates them.

One pound corresponds to approximately 453.6 grams, which is .4536 kilograms. One inch corresponds to 2.54 centimeters, which is .0254 meters. One foot equals twelve inches. Hence:


Last updated 6 May 2005.