Program 1 main content
Student Learning Objectives
- Demonstrate the use of jGRASP to type in, compile, execute, and print-out a simple Java program
- Use Lab 1's pedometer program as a model to follow to fill in the missing Java source code to complete the
BodyMassIndexprintout that was handed out during Lab 1. - Use the jGRASP to type in, compile, debug, execute, and print your
BodyMassIndexprogram stored in folderU:\Program1\
- Use Lab 1's pedometer program as a model to follow to fill in the missing Java source code to complete the
- Demonstrate the use commenting and formatting style to produce readable programs.
- Use the Pedometer and BodyMassIndex printouts as an example of correct programming style conventions.
- Browse through the Java Programming Style Guide for other standards and conventions to use in CS 110.
Program Assignment
You will be given a printout of a partially complete BodyMassIndex program during Lab 1 (or pick it up the printout in class lecture if you missed lab). A screen snapshot of the partially completed program is also available.
Complete the missing Java code, type your program into the computer using jGRASP, and fix any errors.
The program can be used to calculate the user's Body Mass Index (BMI). BMI can be used to indicate if you are overweight, obese, underweight or normal.
Women tend to believe they look their best at BMI values between 20 to 22 and men are usually satisfied with a BMI of 23 to 25.
if your BMI is 30 or more, that's not good. However, this simple BMI calculator tends to overestimate BMI in people who are muscular or athletic. Therefore, if your BMI score seems too high, you're not too fat, your just too athletic.
The formula for calculating BMI is
where w is the user's weight (in kilograms) and h is the user's height (in meters).
There are 2.2 pounds in a kilogram and 39.37 inches in a meter.
Sample Output
What to turn in
BodyMassIndexprogram printout- We do not need a printout of your program's output. To test for correctness we will run your program from the CS network.
- Be sure your project is saved in your U:\Program1\ folder on the computer science network.
- Use "My Computer" to check this.
- Ask your TA at the start of Lab 2 if you need help with this
- The assignment is due at the start of Lab 2.
Grading Criteria
50 points maximum
- 25 points - Output Correctness
- The program calculates and displays the correct calculated values for Body Mass Index with different user input.
- calculated height in meters is correct (5)
- calculated weight in Kilograms is correct (5)
- calculated body mass index is correct (5)
- The output for the program is correctly worded and formatted
- including the required blank line after user input and before output for improved readability. (5)
- Duplicate the sample output exactly, do not make up your own words or formatting. (5)
- The program calculates and displays the correct calculated values for Body Mass Index with different user input.
- 5 points - Algorithm
- Correct use of Java constants and variables in the conversion formulas. (5)
- 10 points - Comments
- Complete file header comments with the assignment, your CS account, name, creation date, completion time, and honor code. Write "no one" if you received no help on your program solution, otherwise indicate the other students who helped you. (3)
- Type in the single-line Java comments given on
BodyMassIndex's printout. (2) - Alignment and indentation are important. Use the programs
Pedometer&BodyMassIndex, and the Java Programming Style Guide for guidance. (5)
- 5 points - Identifier Names
- Use meaningful variable names for the constants and variables used (this is done for you on this assignment).
- Constant names should use all upper case letters with the underscore character between words.
- Variable identifier names should begin with a lower case letter, and each subsequent word should start with an upper-case letter.
- Avoid the use of abbreviations in forming identifier names.
- 5 points - Creation of Assignment Folder, File, and Printouts
- Folder
U:\Program1\created correctly on your network U:\ drive (2) - Java program file saved as
U:\Program1\BodyMassIndex.java(3)
- Folder