Our website provided core java programs examples with output aid beginners and expert coders to test their knowledge gap and learn accordingly.
Body Mass Index (BMI) :
The “Quetelet Index ” is another name for the BMI. It is a value calculated using a person’s weight (in kg) and height (in meters), whether male or female. The body mass index (BMI) is calculated by multiplying the body mass by the square of the body height. BMI is measured in kilograms per square meter.
The BMI is used to determine if a person is underweight, normal weight, overweight, or obese. A table with data from the four categories listed above is provided below.
BMI | Weight Status |
---|---|
Below 18.5 | Underweight |
18.5 – 24.9 | Normal or Healthy Weight |
25.0 – 29.9 | Overweight |
30.0 and Above | Obese |
Formula to calculate BMI :
BMI = [mass/(height*height)]
where mass is the body’s mass in kilograms and
height is the body’s height in meters
Given Height, Weight and the task is to calculate BMI for given input values.
Examples:
Example1:
Input:
Given Height = 2.5 Given Weight = 50
Output:
The BMI for the above given values = 8.0 Health status of a person for the above obtained BMI = The person is Underweight
Example2:
Input:
Given Height = 1.5 Given Weight = 70
Output:
The BMI for the above given values = 31.11111111111111 Health status of a person for the above obtained BMI = The person is Suffering from Obesity
Program to Calculate BMI
Below are the ways to Calculate BMI for Given values of height, weight.
Method #1: Using Mathematical Formula (Static input)
Approach:
- Give the first number as static input and store it in a variable.
- Give the second number as static input and store it in another variable.
- Calculate the BMI Value using the above given mathematical formula and store it in another variable.
- Check If the obtained BMI value is less than 18.5 using the if conditional statement.
- If it is True, Print “The person is Underweight”.
- Check If the obtained BMIÂ is greater than or equal to 18.5 and less than 24.9 using elif conditional statement.
- If it is True, Print “The person is Healthy”.
- Check If the obtained BMIÂ is greater than or equal to 24.9 and less than 30 using elif conditional statement.
- If it is True, Print “The person is Overweight”.
- Check If the obtained BMIÂ is greater than or equal to 30 using elif conditional statement.
- If it is True, Print “The person is Suffering from Obesity”
- The Exit of the program.
Below is the implementation:
# Give the first number as static input and store it in a variable. gvn_heigt = 2.5 # Give the second number as static input and store it in another variable. gvn_weigt = 50 # Calculate the BMI Value using the above given mathematical formula and # store it in another variable. Bmi_vlue = gvn_weigt/(gvn_heigt**2) print("The BMI for the above given values = ", format(Bmi_vlue)) print("Health status of a person for the above obtained BMI = ", end="") # Check If the obtained BMI value is less than 18.5 using if conditional statement . # If it is True, Print "The person is Underweight". if (Bmi_vlue < 18.5): print("The person is Underweight") # Check If the obtained BMI is greater than or equal to 18.5 and less than 24.9 using # elif conditional statement . # If it is True, Print "The person is Healthy". elif (Bmi_vlue >= 18.5 and Bmi_vlue < 24.9): print("The person is Healthy") # Check If the obtained BMI is greater than or equal to 24.9 and less than 30 using # elif conditional statement . # If it is True, Print "The person is Overweight". elif (Bmi_vlue >= 24.9 and Bmi_vlue < 30): print("The person is Overweight") # Check If the obtained BMI is greater than or equal to 30 using # elif conditional statement . # If it is True, Print "The person is Suffering from Obesity" elif (Bmi_vlue >= 30): print("The person is Suffering from Obesity")
Output:
The BMI for the above given values = 8.0 Health status of a person for the above obtained BMI = The person is Underweight
Method #2: Using Mathematical Formula (User input)
Approach:
- Give the first number as user input using float(input()) and store it in a variable.
- Give the second number as user input using float(input()) and store it in another variable.
- Calculate the BMI Value using the above given mathematical formula and store it in another variable.
- Check If the obtained BMI value is less than 18.5 using the if conditional statement.
- If it is True, Print “The person is Underweight”.
- Check If the obtained BMIÂ is greater than or equal to 18.5 and less than 24.9 using elif conditional statement.
- If it is True, Print “The person is Healthy”.
- Check If the obtained BMIÂ is greater than or equal to 24.9 and less than 30 using elif conditional statement.
- If it is True, Print “The person is Overweight”.
- Check If the obtained BMIÂ is greater than or equal to 30 using elif conditional statement.
- If it is True, Print “The person is Suffering from Obesity”
- The Exit of the program.
Below is the implementation:
# Give the first number as user input using float(input()) and store it in a variable. gvn_heigt = float(input("Enter some Random Number = ")) # Give the second number as user input float(input()) and store it in another variable. gvn_weigt = float(input("Enter some Random Number = ")) # Calculate the BMI Value using the above given mathematical formula and # store it in another variable. Bmi_vlue = gvn_weigt/(gvn_heigt**2) print("The BMI for the above given values = ", format(Bmi_vlue)) print("Health status of a person for the above obtained BMI = ", end="") # Check If the obtained BMI value is less than 18.5 using if conditional statement . # If it is True, Print "The person is Underweight". if (Bmi_vlue < 18.5): print("The person is Underweight") # Check If the obtained BMI is greater than or equal to 18.5 and less than 24.9 using # elif conditional statement . # If it is True, Print "The person is Healthy". elif (Bmi_vlue >= 18.5 and Bmi_vlue < 24.9): print("The person is Healthy") # Check If the obtained BMI is greater than or equal to 24.9 and less than 30 using # elif conditional statement . # If it is True, Print "The person is Overweight". elif (Bmi_vlue >= 24.9 and Bmi_vlue < 30): print("The person is Overweight") # Check If the obtained BMI is greater than or equal to 30 using # elif conditional statement . # If it is True, Print "The person is Suffering from Obesity" elif (Bmi_vlue >= 30): print("The person is Suffering from Obesity")
Output:
Enter some Random Number = 1.5 Enter some Random Number = 70 The BMI for the above given values = 31.11111111111111 Health status of a person for the above obtained BMI = The person is Suffering from Obesity
Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.