CSC 230
Test 1 / September 27, 2010

BMI

Based on http://www.whathealth.com/bmi/formula.html

Focus on what you can do; don’t get hung up on the one thing you can’t do.

Comment out code that isn’t working that you want me to look at for partial credit.

·  You must have a comment with your name at the top of your program.

·  Your control names and variable names should be meaningful (e.g. btnCalculate not Button1).

·  Design a form like that shown above.

·  The Form’s color should be anything but default gray. Its ForeColor should be anything but default black. Its font size should be 12-pt.

·  The bar at the top should say Body Mass Index.

·  Place the image of Adolphe Quetelet quetelet.jpg in a PictureBox that is 268×326 on the right-hand side.

·  The TextBox for feet should have a MaxLength of 1 and TextBox for inches should have a MaxLength of 4 (so one can enter a number like 11.5). They should both be right aligned.

·  The NumericUpDown for Weight should have a Minimum of 60, a Maximum of 400, and start with a Value of 150. It should be right aligned.

·  When the Button is clicked, retrieve the data from the Form.

·  Make sure the Feet data is a number and is between 2 and 8. Report any problems to the user using a MessageBox and do not continue with the calculation. Put the Focus back into the TextBox.

·  Make sure the inches data is a number and is between 0 and 11.9. Report any problems to the user using a MessageBox and do not continue with the calculation. Put the Focus back into the TextBox.

·  Calculate the height in inches by multiplying the feet by 12 and adding the inches

HeightInInches = Feet*12 + Inches

·  Calculate the Body-Mass Index (BMI) from any of the following equivalent formulas

BMI = Weight*703 / HeightInInches^2

BMI = Weight*703 / HeightInInches / HeightInInches

BMI = (Weight*703) / (HeightInInches * HeightInInches)

·  Display the resulting BMI using FormatNumber(BMI,1) which will show one decimal place. You must include (somehow) the words “Your BMI is ”.

·  Display the corresponding Weight Status based on the following ranges

Below 18.5 / Underweight
18.5 to 25 / Normal
25 to 30 / Overweight
30 and higher / Obese

·  If the user changes any of the data (Feet, Inches or Weight), the BMI and Weight Status results should be cleared out.

·  When the Clear Button is clicked, the Feet and Inches TextBoxes should be cleared out, the Weight should be set back to 150, and the BMI and Weight Status results should be cleared out.

·  Print out your code (remember your name should be at the top).

·  Zip up the project folder and send it to me in an email.