On This Page
Overview
During this assignment, you will:
- Use conditional expressions to add functionality to mathematical expressions
- Use methods 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 methods. You must implement the following methods, without changing their declaration, though you may implement more methods.
public static void showInstructions(): Displays instructions to the user.
public static 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.
public static 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.
public static 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.
public static int reportResults(double hat, double jacket, double waist): Reports the results of the computations and asks the user if they wish to run again.
Sample Output
- The program runs like the following example:





Additional Specifications
- 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.java.
- Remember to not use magic numbers.
- Do not use packages statements
- Add a comment block like the following just before each method:
/**
* Calculates and returns the hat size.
*
* @param height The height in inches.
* @param weight The weight in pounds.
* @return The hat size in inches.
*/
public static double calcHatSize(int height, int weight)
^ top
Extra Credit
The following are worth extra credit points:
- Complete the assignment using pair programming. (1 point)
- Report numerical results using two decimal places. (1 point)
public static double inputValue(String prompt, double min, double max): Prompts the user to enter a value, reads the value from the keyboard, and verifies that the user entered a value between min and max. If the user enters a value less than min or greater than max, then the method displays 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)

Make certain that your README.txt file describes any extra credit attempted.
^ top
Test Cases
Testing is an important part of software development. Usually, programmers develop tests for each unit of code they produce. This is know as "unit testing" and allows the programmer to verify that the code they develop works correctly.
To assist you in developing your code, I provide tests for this assignment. These tests, known collectively as "test cases", help to make sure that your assignment meets its requirements. I will use these test cases (and perhaps others) to test your assignment, and you should too. If the test cases do not pass, then you will lose points for the assignment.
Install the tests by copying the following file into the same directory as your .java source code files:
Compile and run the tests as you would any other Java program. If the test program does not compile, then your program has an error. If the test reports an error message, then your program has an error.
^ 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 Java 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.java
- 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
| Schedule
| Expectations
| Course info
Help
| FAQ's
| HowTo's
| Links
Last Updated: October 29 2004 @16:42:15
|