University of Pittsburgh
Fall 2003
CS0007:  Introduction to Computer Programming
Assignment 2: BMI
DUE DATE
Monday, Sep 22, midnight
VALUE
20 points
BACKGROUND
Chapter 2, JBD

Have your old handouts ready as a reference and assignment 1.  

Objectives

This assignment is similar in nature to several of the examples we did in class.  You will be following the "calculator" style of program that goes:  (1) get input, (2) calculate answer, (3) print results.  You will be declaring a few variables and using some built-in methods.

What to do

You will write a small program to calculate people's Body Mass Index.  This number is often used in conjuction with weight and body fat percent to give people an idea of their physical health.  The steps to calculate BMI are as follows:
  1. Multiply your weight (in pounds) by 703.
  2. Square your height (in inches).
  3. To get your BMI, divide the result from 1 by the result from 2.
Your program should ask the user for the first two numbers, then print the result. 

Your variables should all be of type double and you should use Console.in.readDouble() from the tio package to read them in.


Sample output

Here is a sample of how your program might look when executed.  You don't have to do exactly this, but it should be similar.

(22) unixs1 $ java youridBMI
Welcome to the BMI calculator.
  Please enter your weight in pounds ==> 350
  Please enter your height in inches ==> 80
Your BMI is: 38.4453125
(23) unixs1 $


The output is kind of ugly, but formatting doubles and floats is not exactly easy, so we'll learn that later.  For now, we'll just live with the extraneous decimal places.

Handing your work in

Don't forget to begin your filename with you user id and to put your name & email in the top comment of your program.

Copy both your java source file and your compiled .class file in the handin directory.  Use assignment2 as the directory name.  See the assignment 1 or the handing your code in handout to remind you of the steps.  Don't forget to verify the handin using ls.

Suggestions/Hints

This is fairly similar to the programs we wrote together in class.  My advice is to model your program after them. 

Last Updated: 9/15/03 by H. Chad Lane