Advertisement
farahfresnido

HOA4

Jan 23rd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. namespace HOA4_12WAL11FresnidoFarah
  2. {
  3. public partial class Form1 : Form
  4. {
  5. public Form1()
  6. {
  7. InitializeComponent();
  8. }
  9.  
  10. private void label1_Click(object sender, EventArgs e)
  11. {
  12.  
  13.  
  14. }
  15.  
  16. private void button1_Click(object sender, EventArgs e)
  17. {
  18. string weight1 = textBox1.Text;
  19. string height1 = textBox2.Text;
  20.  
  21. if ((textBox1.Text == "" || textBox2.Text == "") || (textBox1.Text == "" && textBox2.Text == ""))
  22. {
  23. MessageBox.Show("Error: Don't leave anything blank.");
  24. }
  25. else if (textBox1.Text != "" && textBox2.Text != "")
  26. {
  27. double weight = double.Parse(textBox1.Text);
  28. double height = double.Parse(textBox2.Text);
  29.  
  30. double BMI = (weight * 0.45) / ((height * 0.025) * (height * 0.025));
  31. label3.Text = "BMI: " + BMI;
  32.  
  33. textBox1.Text = "";
  34. textBox2.Text = "";
  35. }
  36. }
  37.  
  38. private void button2_Click(object sender, EventArgs e)
  39. {
  40. string start1 = textBox3.Text;
  41. string end1 = textBox4.Text;
  42.  
  43. if ((textBox3.Text == "" || textBox4.Text == "") || (textBox3.Text == "" && textBox4.Text == ""))
  44. {
  45. MessageBox.Show("Error: Don't leave anything blank.");
  46. }
  47. else if (textBox3.Text != "" && textBox4.Text != "")
  48. {
  49. double start = double.Parse(textBox3.Text);
  50. double end = double.Parse(textBox4.Text);
  51.  
  52. if (end < start)
  53. {
  54. MessageBox.Show("Error: Starting value has to be less than the ending value.");
  55. }
  56. else if (end > start)
  57. {
  58.  
  59. double n = end - start + 1;
  60. double sum = n * ((end + start) / 2);
  61.  
  62. label6.Text = "The sum is " + sum;
  63.  
  64. textBox3.Text = "";
  65. textBox4.Text = "";
  66. }
  67. }
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement