//Programmer: Janet Joy //Calculate BMI: Body Mass Index //BMI=703*pounds/(inches*inches) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace BMIndex { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void hsbInches_Scroll(object sender, ScrollEventArgs e) { //Display the inches from scrollbar as feet and inches, ex. 5'3" int feet = hsbInches.Value / 12; int inches= hsbInches.Value % 12; lblInches.Text=""+feet+"'"+inches+"\""; calculateBMI(); } private void hsbPounds_Scroll(object sender, ScrollEventArgs e) { //Display the pounds from scrollbar lblPounds.Text = hsbPounds.Value.ToString(); calculateBMI(); } private void calculateBMI() { //Calculate BMI: Body Mass Index when either scroll bar changes //BMI=703*pounds/(inches*inches) //Divide by 0 error will occur if inches is 0 int inches = hsbInches.Value; int pounds = hsbPounds.Value; if(inches>0) { int bmi = 703 * pounds / (inches * inches); lblBMI.Text = bmi.ToString(); } } } }