PIC20A

HW 1: Are you overweight?

Assignment

This is a very easy Homework. You are going to write a program to calculate Body Mass Index. Then tell the user if he/she is overweight or not.
Body Mass Index is given by
Your Weight (in pounds) x 704.5 divided by (Your Height (in inches) x Your Height (in inches))
Here is a table from this link.

Adults BMI: Women Men
underweight < 19.1 < 20.7
in normal range 19.1 - 25.8 20.7 - 26.4
marginally overweight 25.8 - 27.3 26.4 - 27.8
overweight 27.3 - 32.3 27.8 - 31.1
very overweight or obese > 32.3 > 31.1

Sample Program

You can download the program BMI.class on your computer. After you download it, open a DOS prompt, use cd to change to the correct folder.

Sample Section

java BMI gender height(in inches) weight(in pounds)
gives the body mass index of the given height and weight.
gender is a character (m, M, f, F).
height and weight are doubles.
You can assume the user uses the correct syntax. i.e. you don't have to do error checking.
java BMI m 78 200
Your Body Mass Index is 23.159105851413543
You have a healthy weight.

java BMI f 60 88
Your Body Mass Index is 17.22111111111111
You are underweight.

java BMI F 67 166.5
Your Body Mass Index is 26.130374248162173
You are marginally overweight.

java BMI M 85 320
Your Body Mass Index is 31.202768166089964
You are very overweight.

java BMI m 72 220
Your Body Mass Index is 29.897762345679013
You are overweight.


What to submit

Call your source code file BMI.java. Put this file in your submit folder. Do not place this file inside another folder within your submit folder.

Remark

Properly formatted, this information should appear as follows:(Please change the Name, Student ID, PIC ID, E-mail, Discussion
/** Name:        Charles Li 
  * Student ID : 000 000 000   
  * PIC ID:      ccli 
  * E-mail:      ccli@math.ucla.edu 
  * Discussion:	 1A, Baber
  * Assignment:	 hw1 
  * 
  * I, Charles Li, pledge that this is my own independent work, which  
  * conforms to the guidelines of academic honesty as described in the course  
  * syllabus.  
  * 
  */

Solution

BMI.java