0% found this document useful (0 votes)
6 views2 pages

BMI Calculator Application

The document describes creating a BMI calculator application with a form that takes height and weight inputs and calculates BMI, then displays the result along with an indicator of underweight, normal, overweight, or obese status. Code is provided to handle button click event to perform calculations and set outputs.

Uploaded by

ravinduashan66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

BMI Calculator Application

The document describes creating a BMI calculator application with a form that takes height and weight inputs and calculates BMI, then displays the result along with an indicator of underweight, normal, overweight, or obese status. Code is provided to handle button click event to perform calculations and set outputs.

Uploaded by

ravinduashan66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Visual Application Programming Practical – By S.

Garigaraganapathy, ATI Jaffna

BMI Calculator Application

Design a Form as given below:

Type the given code to click event of the button:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HNDITFT2020
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void btnCalculate_Click(object sender, EventArgs e)


{
double bmi;
bmi = Convert.ToDouble(txtWeight.Text) / (Convert.ToDouble(txtHeight.Text) *
Convert.ToDouble(txtHeight.Text));
txtBMI.Text = bmi.ToString();
if (bmi < 18.5)
{
txtStatus.Text = "Under Weight";
txtIndicator.BackColor = Color.Red;
}
else if (bmi<25)
{
txtStatus.Text = "Normal";
txtIndicator.BackColor = Color.Blue;
}
else if (bmi < 30)
{
txtStatus.Text = "Over Weight";
txtIndicator.BackColor = Color.Green;
}
else if (bmi < 35)
Visual Application Programming Practical – By S.Garigaraganapathy, ATI Jaffna

{
txtStatus.Text = "Obesity Class I";
txtIndicator.BackColor = Color.Orange;
}
else if (bmi < 40)
{
txtStatus.Text = "Obesity Class II";
txtIndicator.BackColor = Color.Pink;
}
else
{
txtStatus.Text = "Obesity Class III";
txtIndicator.BackColor = Color.Brown;
}
}
}
}

Sample Output:

You might also like