RU beehive logo ITEC dept promo banner
ITEC 120
2007fall
ibarland,
jdymacek

homeinfoexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs

hw-ec01-bmi
extra credit homework: Body Mass Index
Due Nov.29 (Thu) in class

Write the following functions (in order, without skipping any). Strive for neat-looking, well-organized code1 which follows The Laws of Programming. For each function, include comments, signature, and test cases.

  1. (5pts) feetAndInchesToMeters: Example: If somebody is 6′4½″ tall, they are 1.9431m tall. There are two inputs to this function: a number of feet, and a number of additional inches. (There are 2.54cm/in -- a fine candidate for a named constant.)
  2. (5pts) lbsToKg. Example:If somebody weights 220.46lbs, they weigh 100kg.
  3. (5pts) bodyMassIndex: Somebody who weighs 220lbs and is 6′4½″ tall has a body mass index of 26.4 (approx). Write a function which, given a person's weight (in pounds) and height (how many feet and how many inches), returns their body mass index. The general formula for BMI is simple: The person's weight in kg, divided by their height in meters squared.2
  4. (5pts) bodyMassIndexType: Given the same info as the previous problem, return the person's weight category.
    BMI intervalcategory
    [0,18) underweight
    [18,25) normal
    [25,30) overweight
    [30,∞) obese
    Note that the BMI scale has its limitations, and one recent study suggests that while the “normal” range might correlate with best health, it may not have the highest longevity.

Printing the hard copy

When printing the hardcopy, have the top sheet be your documentation (the interface view). Alas, since BlueJ curiously omits a 'print' button when you are in interface view, you can print your documentation as follows:

  1. Open a web browser;
  2. Choose File > Open File… (as opposed to opening a web location (URL))
  3. Navigate into your BlueJ project folder for the assignment, inside the docs folder, and find the .html for your class there.
  4. Print the page from your browser.

If you used BlueJ's unit test facility, also print out unit test class for your program. (Also, attach that .java file in WebCT/Blackboard as well.)


1It's possible to have a function which gives the correct answers, but with no test cases, no named constants, and bad indentation it could get zero points.      

2 This formula takes a person's weight, adjusting for how tall they are. The squaring stems from the fact that if person A is (say) 10% taller than person B, then A is allowed by to 10% wider, but not 10% thicker. So you square the person's height, rather than cube it.      

homeinfoexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs


©2007, Ian Barland, Radford University
Last modified 2007.Nov.16 (Fri)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme