Professional Documents
Culture Documents
NO : 12
DATE :
BMI CALCULATOR
Kavya E , Karunapriya S , Sivapriya P
B.E III year CSE C section
ABSTRACT:
BMI (Body Mass Index) is a number calculated from a person's weight and height. BMI is a fairly
reliable indicator of body fatness for most people. Additionally, BMI is an inexpensive and easy-to-
perform method of screening for weight categories that may lead to health problems. It is a measurement
of a person's leanness or corpulence based on their height and weight, and is intended to quantify tissue
mass. It is widely used as a general indicator of whether a person has a healthy body weight for their
height. Specifically, the value obtained from the calculation of BMI is used to categorize whether a
person is underweight, normal weight, overweight, or obese depending on what range the value falls
between. These ranges of BMI vary based on factors such as region and age, and are sometimes further
divided into subcategories such as severely underweight or very severely obese. Being overweight or
underweight can have significant health effects, so while BMI is an imperfect measure of healthy body
weight, it is a useful indicator of whether any additional testing or action is required.
SOURCE CODE
Activity_main.xml
< RelativeLayout xmlns:android="http://schemasandroid.com/apk/res/android
xmlns:app="http•//schemas.android.com/apk/res-auto'
xmlns:tools="http://schemas.android.com/tools' android:layout_width="match_parent"
tools:context=". MainActivity">
<TextView
android:textStyle="bold" />
<TextView
android:text="Weight(in Kg)"
android:textStyle="bold'
app:layout_constraintBottom_toBottomOf="parent
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf='Þarent"
app:layout_constraintVertical_bias='0292" />
<EditText
<TextView
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf='Þarent"
<EditText
android:textSize='20dp" />
<Button
android:backgroundTint="#2CD3BE
android:text="Calculate" />
<TextView
android•id='@+id/bmi_tv"
android:text="The BMI is
android:textSize='20dp"
android:visibility="gone" />
<TextView
android:text="BMl"
android:visibility="gone" />
<TextView
android:textStyle="bold'
android:visibility="gone" />
<Button
android:text="Calculate"/>
</RelativeLayout>
MainActivity.java
package com-example.bmi;
import android.app.Activity;
import android.view.View;
private TextView tv 1
privateRelativeLayout rl ;
@override
super.onCreate(savedlnstanceState);
setContentView(R.layout.activity_main);
calculate_btn.setOnClickListener {
bmi.text = BMI.toString();
bmi.visibility = View.VlSlBLE;
bmi_tv.visibility = View.VISIBLE ;
status.visibility = View.VISIBLE;
Calculate.visibility = View.VISIBLE;
calculate_btn.visibility = View.GONE;
else {
Toast.makeText(this, "please enter the valid height and weight",
;
Calculate.setOnClickListener {
ResetEverything();
}
// Function to reset all Text and EditText fields
private fun ResetEverything() {
calculate_btn.visibility = View.VlSlBLE;
ReCalculate.visibility = View.GONE;
etHeight.text.clear();
etWeight.text.clear();
bmi_tv.visibility = View.GONE;
return BMI;
}
OUTPUT: