Welcome to Project ready digitechbits tutorial Today we will Learn How to create BODY MASS INDEX Calculator

General Information

BMI is defined as the ratio of the mass and height-squared with the formula below:

BODY MASS INDEX (BMI) Calculator

After the calculation of the BMI, the following table is the used for assessing the weight category:

open your Android Studio, if you don’t have click here to download

BODY MASS INDEX (BMI) Calculator

After setting up above command then follow next step

add Text View in Next step

I have changed the text font sizes to 18 sp and made the text type bold. The layout seems like in Figure after changing the texts of these TextViews per our aim.

BODY MASS INDEX (BMI) Calculator

Now we add require field so follow next step

I also positioned its default text in the middle as we did before.

Now we follow the next step

BODY MASS INDEX (BMI) Calculator

above is the GUI of the app after setting up all TextFields.

Above we placing the button on the screen.After these steps, the GUI of our app is ready as shown below:

Developing the Main Code of the App

 Firstly, the values entered in the weight input and height input text fields will be taken. These will be String type variables.
 Convert these Strings to double type variables so that the BMI calculation can be performed using the BMI equation given at the beginning of the chapter.
 Perform the body mass index calculation.
 Display the BMI value in the text field next to the “Your BMI:” label after converting to String type.
 Use if–else statements to determine the BMI category from the BMI value using the aboveTable.
 Display the BMI category in the text view which shows “BMI category appears here.” by default.

Please open the MainActivity.java file from the file explorer of Android Studio. The default contents of this file are as follows:

this is the code for BODY MASS INDEX (BMI) Calculator.enjoy it keep learning!

For more tutorial about android studio click here

Leave a Reply

Your email address will not be published.