Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *TextBox1=weight
- 2=height
- 3=end
- 4=start
- *button 1 = bmi
- 2 = sum
- 3 = reset bmi
- 4 = reset sum
- namespace esetydtyrdrt
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- if (TextBox1.Text == "" || TextBox2.Text == "")
- {
- MessageBox.Show("Error: Do not leave anything blank.");
- }
- else if (TextBox1.Text != "" && TextBox2.Text != "")
- {
- double weight = double.Parse(TextBox1.Text);
- double height = double.Parse(TextBox2.Text);
- double BMI = (weight * 0.45) / ((height * 0.025) * (height * 0.025));
- Label3.Text = "BMI: " + BMI;
- }
- }
- private void Button2_Click(object sender, EventArgs e)
- {
- if (TextBox3.Text == "" || TextBox4.Text == "")
- {
- MessageBox.Show("Error: Do not leave anything blank.");
- }
- else if (TextBox3.Text != "" && TextBox4.Text != "")
- {
- double start = double.Parse(TextBox4.Text);
- double end = double.Parse(TextBox3.Text);
- if (start < end)
- {
- double n = end - start + 1;
- double sum = n * ((start + end) / 2);
- Label4.Text = "The sum is " + sum;
- }
- else if (start > end)
- {
- MessageBox.Show("Error: The start has to be less than the end.");
- }
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- TextBox1.Text = "";
- TextBox2.Text = "";
- Label3.Text = "BMI: ";
- }
- private void button4_Click(object sender, EventArgs e)
- {
- TextBox3.Text = "";
- TextBox4.Text = "";
- Label4.Text = "Sum: ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement