

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An exercise for students in csci 1301 lab to enhance their java application from lab #4. The exercise requires students to modify the main method of the bmi class to validate user input for weight and height, compute bmi score, and determine weight category based on the score. The document also includes examples and hints.
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


The purpose of this exercise is to apply your knowledge about assignments statements, arithmetic expressions and conditional statements discussed during the lectures.
In this lab exercise, you will enhance the functionality of the java application you implemented in Lab #4. Your java application will, as before, compute the Body Mass Index (BMI) according to a person's weight and height but it will also perform input validation and determine the weight category of the user. For this exercise, modify the main method of the class BMI you wrote in Lab #4 to do the following: a) The program should prompt the user for his/her weight in kilograms, if the user enters a number less than zero the program will display a message and terminate. b) Afterwards, the program should prompt the user for his/her height in meters, if the user enters a number less than zero, the program will display a message and terminate. c) Then the program will compute the BMI of the user as:
height^2 meters
weightkgs BMI =
d) After computing the user’s BMI score, the program will display:
BMI Score Weight Category Less than 18.5 Underweight Greater than or equal to 18.5 and less than 25 Normal Greater than or equal to 25 and less than 30 Overweight Greater than or equal to 30 Obesity
e) Additionally, your program will display a disclaimer that states the limitations of the BMI as follows:
Disclaimer: The BMI score is valid for both men and women but it does have some limits. The limits are: a) It may overestimate body fat in athletes and others who have a muscular build. b) It may underestimate body fat in older persons and others who have lost muscle mass.
Example #1:
Height in meters:-10. Sorry, -10.2 is not a valid height in meters. Bye.
Example #2:
Height in meters:1. Weight in kgs: -15. Sorry, -15.5 is not a valid weight in kilograms. Bye.
Example #3: Height in meters:1. Weight in kgs:
User’s Information: Weight: 92.0 kgs. (202.4 lbs.) Height: 1.89 m. (6' 2") BMI: 25. Weight group: Overweight (*)
(*) Disclaimer:
The BMI score is valid for both men and women but it does have some limits. The limits are: a) It may overestimate body fat in athletes and others who have a muscular build. b) It may underestimate body fat in older persons and others who have lost muscle mass.
Hints:
Compile and run your program.
After you have completed this exercise, demonstrate it to your lab instructor.
After you have completed both exercises in this lab, upload the file BMI.java in WebCT and submit it to receive credit.