ITEC 120 LAB 5 Back to Lab index page

Pre-lab exericise - electronically submit a file to neelix.

On Friday you will take a lab quiz -- and you will submit your java program to your folder in the dropbox on neelix to turn it in. Practice submitting a file to neelix today so we can make sure everything works and that you understand the process for turning in your work on Friday.

Get example2.java from your H: drive and put it in your folder on neelix:

Ideal Weight

Write a program to compute the ideal weight for both males and females.

According to one study, the ideal weight for a female is 100 pounds plus 5 pounds for each inch in height over 5 feet. For example, the ideal weight for a female who is 5'3" would be 100 + 15 = 115 pounds. For a male the ideal weight is 106 pounds plus 6 pounds for each inch in height over 5 feet. For example, the ideal weight for a male who is 6'2" would be 106 + 14*6 = 190 pounds. Your program should ask the user to enter his/her height in feet and inches (both as integers-so a person 5'3" would enter the 5 and the 3). It should then compute and print both the ideal weight for a female and the ideal weight for a male. (For this problem you may assume heights of 5 feet or more. )

The general outline of your main function would be as follows:

Plan your program, then type it in, compile and run it. Be sure it gives correct answers.

Lab Challenge (optional!) - The weight program would be a bit nicer if it didn't just give one number as the ideal weight for each sex. Generally a person's weight is okay if it is within about 15% of the ideal. Add to your program so that in addition to its current output it prints an okay range for each sex - the range is from the ideal weight minus 15% to the ideal weight plus 15%. You may do this by introducing new variables and assignment statements OR directly within your print statements.

Sample 1

Program outputs: Please enter a height (in feet):
User inputs: 5
Program outputs: Please enter a height (in feet):
User inputs: 4
Program outputs:

The ideal weight for a 5 foot 4 inch female is: 120 pounds.

The ideal weight for a 5 foot 4 inch male is: 130 pounds.