using System;
using System.Windows.Forms;
namespace _28689122
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int ok = 0;
if (String.IsNullOrEmpty(textHeight.Text)) {
MessageBox.Show("Height must not be Empty");
ok = 1;
}
if (String.IsNullOrEmpty(textName.Text))
{
MessageBox.Show("Name must not be Empty");
ok = 1;
}
if (ok == 0) {
try {
int result = int.Parse(textHeight.Text);
}
catch {
MessageBox.Show ("Height Not a valid integer");
return;
}
try {
double result = double.Parse(textWeight.Text);
}
catch
{
MessageBox.Show("Weight Not a valid integer");
return;
}
int Height = Convert.ToInt32(textHeight.Text);
double Weight = Convert.ToDouble(textWeight.Text);
double BMI = Weight / Math.Pow(Height / 100.0, 2);
MessageBox.Show ("Name: "
+ textName.Text + Environment.NewLine
+ "Height: " + Height + Environment.NewLine
+ "Weight: " + Weight + Environment.NewLine
+ "BMI: " + BMI);
}
}
}
}
https://www.microsoft.com/en-us/download/details.aspx?id=46148