On This Page
Overview
During this assignment, you will:
- Use conditional expressions to add functionality to mathematical expressions
- Use functions to organize your program design
- Optionally, handle user input errors
^ top
Specifications
Write a program that asks for the user’s height, weight and age, and then computes clothing sizes according to the formulas provided in the following functions. You must implement the following functions, without changing their declaration, though you may implement more functions.
void showInstructions(): Displays instructions to the user.
double calcHatSize(double height, double weight): Computes the hat size, where hat size = weight in pounds divided by height in inches and all that multiplied by 2.9.
double calcJacketSize(double height, double weight, double age): Estimates the jacket size, where the jacket size (chest in inches) = height times weight divided by 288 and then adjusted by adding 1/8 of an inch for each 10 years over age 30.
Note that the adjustment only takes place after a full 10 years. So, there is no adjustment for ages 30 – 39, but 1/8 of an inch by age 40.
double calcWaistSize(double weight, double age): Calculates the waist size, where the waist in inches = weight divided by 5.7 and then adjusted by adding 1/10 of an inch for each 2 years over age 28.
Note that the adjustment only takes place after a full 2 years. Thus, there is no adjustment for age 29, but 1/10 of an inch is added for age 30.
void reportResults(double hat, double jacket, double waist): Reports the results of the computations.
Sample Output
Give me your height in inches, weight in pounds, and age in years
and I will give you your hat size, jacket size (inches at chest)
and your waist size in inches.
Enter the height in inches: 73
Enter the weight in pounds: 175
Enter the age in years: 39
Hat size = 6.95
Jacket size = 44.36
Waist size = 31.20
Enter Y or y to repeat (any other character ends): n
Additional Specifications
- You must report results with the same words as shown above.
- Report numerical results using two decimal places.
- Allow the user to repeat this calculation as often as the user wishes.
- You may assume that the user will enter correct data only, unless you implement the extra credit.
- The name of the program source code file must be
sizer.cpp.
- Remember to not use magic numbers.
- Add a comment block like the following just before each function declaration (prototype):
/**
* Calculates and returns the hat size.
*
* @param height The height in inches.
* @param weight The weight in pounds.
* @return The hat size in inches.
*/
double calcHatSize(double height, double weight);
^ top
Extra Credit
The following are worth extra credit points:
- Complete the assignment using pair programming. (1 point)
double inputValue(double min, double max): Gets a value from the user using cin and verifies that the user enters a value between min and max. If the user enters a value less than min or greater than max, then the function prints an error message and asks the user to re-enter the number. When the user enters a correct value, the function returns the value as a double. Choose appropriate values for the range. (2 points)
Enter the height in inches: -1
Incorrect value -- please enter again: 73
Enter the weight in pounds: 3
Incorrect value -- please enter again: 175
Enter the age in years: 1000
Incorrect value -- please enter again: 39
Make certain that your README.txt file describes any extra credit attempted.
^ top
Grading Criteria
The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.
Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.
For information on grading policies, including interpretation of scores, see the course information page.
Program Compilation
- 4: Source code compiles with no errors or warnings
- 2: Source code compiles with warnings
- 0: Does not compile or wrong file turned in
Functionality
- 10: Demonstrates mastery of the assignment
- Has extra features or demonstrates techniques beyond the assignment
- Applies concepts from the lesson(s) appropriately
- Meets all specifications (see above) with particularly elegant solutions
- Runs to completion with no abnormal error conditions
- Generates correct output given correct input
- Behaves in a reasonable way in response to incorrect data
- All test cases pass
- 8: Has all the functionality expected of the assignment
- Demonstrates many techniques from the lesson
- Meets all specifications (see above)
- Implementation seems more complicated than necessary.
- May have one minor error
- All test cases pass
- 6: Has most of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets all but one of the specifications (see above)
- Implementation seems excessively complicated.
- May have 2-3 minor errors
- All but one test case passes
- 4: Has some of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets at least 1/2 of the specifications (see above)
- Implementation seems excessively complicated.
- May have more than 3 minor errors
- At least 1/2 of all test cases pass
- 2: Serious functional problems but shows some effort and understanding
- Meets less than 1/2 of the of the specifications (see above)
- Has a major error or many minor errors
- Implementation seems very convoluted
- Demonstrates few techniques from the lesson
- Less than 1/2 of all test cases pass
- 0: Does not execute or no specifications met
Programming Style
- 4: Code is well-documented
- Name, date, and program description in file comment block
- Follows specified format for file comment block
- Proper use of spaces around operators
- No tab characters are present in the source code
- As described in How To Document and Organize C++ Code
- 3: Code has minor documentation errors
- Has 1 documentation error
- 2: Code has some documentation errors
- Has 2-3 documentation errors
- 1: Code has many documentation errors
- Has more than 3 documentation errors
- 0: No apparent attempt to document code
REAME.txt File
- 2:
README.txt file submitted with specified information included
- 1:
README.txt file submitted but some information was missing
- 0: No
README.txt file submitted
Maximum Score: 20, plus extra credit
^ top
What to Turn In
Submit your assignment following the instructions for homework. Include the following items for grading:
README.txt file
sizer.cpp
- Any other source code needed to make your program function.
You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files unless explicitly stated by the instructor. Your assignment must work as submitted.
^ top
Home
| WebCT
| Announcements
| Day Schedule
| Eve Schedule
Course info
| Help
| FAQ's
| HowTo's
| Links
Last Updated: October 23 2004 @20:36:25
|