# Learn to create a BMI Calculator App for Android

In this tutorial, you are going to learn you how to create a Body Mass Index Calculator for Android. This tutorial is ideal for beginners that want to discover how to create a first application. You can discover the tutorial in video on Youtube :

You can also try the application created in this tutorial, with some UI improvements, by downloading BMI Calculator on the Google Play Store :

The Body Mass Index (BMI) or Quetelet index is a value derived from the mass weight and height of an individual. The BMI is defined as the body mass divided by the square of the body height, and is universally expressed in units of kg/m². By analyzing the BMI value, we can determine a diagnostic. First step for the application is to define a layout letting users to enter weight and height values to calculate the BMI index. Besides, we will need a button to launch the BMI calculation and also a TextView to display the result.

The layout will have the following form :

Now, we can write the Java code in our Main Activity :

When a user click on the calculate BMI button, the calculateBMI method is called. We get the values entered by the user for the weight and the height. The height is entered in centimeter. For the formula, we need to have a height in meter. So, we divide the value entered by 100. Then, we apply the formula to calculate the BMI :

float bmi = weightValue / (heightValue * heightValue);

With the BMI value, we can display the result on the user interface. We define the displayBMI method for that. To determine the diagnostic associated to the BMI value, we are going to use the following table :

The last step is just to display the BMI value and the diagnostic in the result TextView. After that, you can try the application and enjoy the BMI Calculator in action :

To discover more tutorials on Android Development, don’t hesitate to visit my blog : https://www.ssaurel.com/blog

Entrepreneur / Developer / Blogger / Author. In Bitcoin We Trust: https://inbitcoinwetrust.substack.com/

Entrepreneur / Developer / Blogger / Author. In Bitcoin We Trust: https://inbitcoinwetrust.substack.com/