Body Mass Index (BMI) Calculator App Create a BMI calculator app (using Android
ID: 3727434 • Letter: B
Question
Body Mass Index (BMI) Calculator App
Create a BMI calculator app (using Android Studio) that allows users to enter their weight and height and whether they are entering these values in English or Metric units, then calculates and displays the user's body mass index. The app shoiuld also display the following information from the Department of Health and Human Services/National Institute of Health so the user can evaluate his/her BMI:
BMI values:
Underweight : less than 18.5
Normal: between 18.5 and 24.9
Overweight: between 25 and 29.9
Obese: 30 or greater
BMI = weightInPounds x 703
heightInInches x heightInInches
or
BMI = weightInKilograms
heightInMeters x heightInMeters
Using the class Toast display the BMI value and the category (if is Underweight, Normal, Overwieight or Obese). The Toast message must be display at the center of the activity.
Explanation / Answer
Activity_main.xml
XML file provide basic environment or design for your android application. By using different views and layouts you can design application of your choice. For this you just have to know the basic XML Tags for designing interface.
Java codes
While we create our project at that time an XML file and a java file is created separately. MainActivity.java is the file where we do coding for java to implement logic and functionality in the app.
MainActivity.java
After you have designed your application using XML coding, you have to use the JAVA code so that when ‘Calculate’ button is clicked, it calculates the value and show you the desired result. This is done after designing the user interface. Java file can be found in your project in src folder.