You are to write a Java console application that calculates and classifies BMI (Body Mass Index) for individuals. The number of individuals (N) is fixed at 10, so it should be declared as final int N = 10 in your program.
BMI is calculated using the following equation:
BMI = weight / (height*height)
where weight is in kilograms and height is in metres.
Wikipedia (https://en.wikipedia.org/wiki/Body_mass_index) defines the following 8 categories for BMI:
Category | BMI (kg/m2) | |
Very serverly underweight | 15 | |
Severely underweight | 15 | 16 |
Underweight | 16 | 18.5 |
Normal (healthy weight) | 18.5 | 25 |
Overweight | 25 | 30 |
Obese Class I (Moderately obese) | 30 | 35 |
Obese Class II (Serverely obese) | 35 | 40 |
Obese Class III (Very serverely obese) | 40 |
For each person, you are to enter their weight (in kilograms) and height (in metres).The application is to then calculate and display the BMI, together with the corresponding 8 level category. When all data has been entered, a summary report consisting of
1. The lowest BMI
2. The highest BMI
3. The average BMI
4. The number of individuals with normal BMI
5. The number of individuals with higher than normal BMI
6. The number of individuals with lower than normal BMI
is displayed.
Normal, low and high BMI values are defined according to the table below:
Category | BMI (kg/m2) | |
From | To | |
Low | 18,5 | |
Normal (healthy weight) | 18.5 | 25 |
High | 25 |
Below is example output for N = 3
Your welcome message goes here ...
Height for person 1 (m): 1.82
Weight for person 1 (kgs): 80
BMI for person 1: 24.2 which is normal (healthy weight)
Height for person 2 (m): 1.82
Weight for person 2 (kgs): 100
BMI for person 2: 30.2 which is moderately obese
Height for person 3 (m): 1.82
Weight for person 3 (kgs): 60
BMI for person 3: 18.1 which is underweight
Summary
*******
Lowest BMI : 18.1
Highest BMI : 30.2
Average BMI : 24.2
Number with low BMI: 1
Number with normal BMI: 1
Number with high BMI: 1
Your exit message goes here ...
Your application is to follow the same format for input and output as in the example above, but with customised welcome and exit messages.
The application is to use the following classes and methods:
public class BMICalculator {
public BMICalculator() {
// no code required
}
public double value( double weight, double height ) {
// return BMI;
}
public String classification8( double bmi ) {
// return the 8 category (Wikipedia) classification for this BMI
}
public String classification3( double bmi ) {
// return the 3 category (high, normal, low) classification for this BMI
}
}
public class Assignment1 {
// no attributes required
public static void main(String[] args) {
// local variable declarations go here
// display welcome message
// loop to input an individual’s height and weight and calculate and display BMI, calculate
summary values
// generate and display summary
// display exit message
}
}