Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CSE114 Fall 2015
Lab Exercise 1 of Week 2
Compute and Interpret Body Mass Index (BMI)
Chen-Wei Wang
Problem
Body Mass Index (BMI) is a measure of health based on height and weight specified in metric units (i.e.,
meters and kilograms, respectively). Given a user weighting k kilograms and who is m meter tall, their
BMI is calculated as:
BMI =
k
m2
Once the BMI is calculated, one should consult with the following table to interpret the result:
BMI Range Interpretation
BMI < 18.5 Underweight
18.5 ≤ BMI < 25.0 Normal
25.0 ≤ BMI < 30.0 Overweight
30.0 ≤ BMI Obese
For example, say Jim weights 76.2 kilograms and is 1.73 meters tall, then his BMI is:
BMI =
76.2
1.732
= 25.4602559391
By consulting the above table, we conclude that Jim is overweight.
Your Task
Your task is to write a Java program for the above calculation and interpretation. However, it is required
that your program does not directly prompt the user for their height and weight in metric units. Instead,
prompt them for their height and weight in imperial units (i.e., inches and pounds). Your program is
going to do the conversion into metric units before calculating the BMI. For your information: 1 pound
is equal to 0.45359237 kilograms, and 1 inch is equal to 0.0254 meters. Also, your program should first
prompt the user for their name, so that you can mention their name when asking for their height and
weight. Here is a sample run for your program:
Enter your name:
Jim
Jim, enter your height in inches:
68
Jim, enter your weight in pounds:
168
Jim, your BMI is 25.54407074471589
Your are overweight!
First of all, create a Java class ComputeAndInterpretBMI in Eclipse, and use the code completion
feature in Eclipse to get the skeleton of the main method. Define your solution as the implementation
body of the main method.
1