Post 5 - Build BMI Calculator using Java

Welcome to the Blog !! Today we will learn to build our own BMI (Body Mass Index) calculator which will help us to decide our BMI Category (Underweight ,  Normal Weight ,  Overweight , Obesity). 

✅ Problem Statement :

Build a BMI calculator which will take height and weight of a person as an input and displays calculated BMI and BMI Category as an Output.

🔴 BMI Categories :
  1. Underweight - If BMI <=18.5
  2. Normal Weight - If BMI is in between 18.6 - 24.9
  3. Overweight - If BMI is in between 25 - 29.9
  4. Obesity - If BMI is greater than 30 

📑Let's Code :)

Note* : If you are not familiar with Eclipse IDE please check my previous posts. This post will not contain basics of Eclipse.

Step 1 :  Follow this -
Open Eclipse  Open Project / Create Project (bmiCalculator) → Create Package (bmiCalculator) →  Create 2 Java Classes , BmiCalculator.java and Main.java

- BmiCalculator.java will contain all the methods to calculate BMI and to decide BMI category.
- Main.java will contain main( ) method to test those functionalities.

Step 2 : Firstly, we will complete BmiCalculator.java -  
This class contains -
  • Getters and Setters
  • Method to calculate BMI
  • Method to decide BMI Category
Here is the sample code for BmiCalculator.java :

BmiCalculator.java 1.1

BmiCalculator.java 1.2

Step 3 : Now we will complete Main.java 
This class contains -
  • main ( ) method
  • Objects of Scanner class and BmiCalculator class
  • Take input from user
  • Call respective methods to compute the results
  • Display result on the Console using prinf( ) method and println( ) method of  Output Stream
Main.java 2.1

Step 4 : Let's Run the Project and Check the Output :)

Here is the Sample Output

Output 1


Output 2


Yeahhh 🎉🥳 We are done with one more project 😄😄 
Check Source Code of this Project Here

Hope you like this post 😉
You can reach us by entering your details in Contact Us box in the side panel💬

All the Best 👍👍👍👍
Happy Learning 😇😇😇

Post a Comment

Comments :

Previous Post Next Post