Advertisement
farahfresnido

HOA4 & HOQ prac !

Jan 27th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1.  
  2. *TextBox1=weight
  3. 2=height
  4. 3=end
  5. 4=start
  6.  
  7. *button 1 = bmi
  8. 2 = sum
  9. 3 = reset bmi
  10. 4 = reset sum
  11.  
  12. namespace esetydtyrdrt
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void Button1_Click(object sender, EventArgs e)
  22. {
  23. if (TextBox1.Text == "" || TextBox2.Text == "")
  24. {
  25. MessageBox.Show("Error: Do not leave anything blank.");
  26. }
  27.  
  28. else if (TextBox1.Text != "" && TextBox2.Text != "")
  29. {
  30. double weight = double.Parse(TextBox1.Text);
  31. double height = double.Parse(TextBox2.Text);
  32.  
  33. double BMI = (weight * 0.45) / ((height * 0.025) * (height * 0.025));
  34.  
  35. Label3.Text = "BMI: " + BMI;
  36. }
  37.  
  38.  
  39. }
  40.  
  41. private void Button2_Click(object sender, EventArgs e)
  42. {
  43. if (TextBox3.Text == "" || TextBox4.Text == "")
  44. {
  45. MessageBox.Show("Error: Do not leave anything blank.");
  46. }
  47.  
  48. else if (TextBox3.Text != "" && TextBox4.Text != "")
  49. {
  50. double start = double.Parse(TextBox4.Text);
  51. double end = double.Parse(TextBox3.Text);
  52.  
  53. if (start < end)
  54. {
  55. double n = end - start + 1;
  56. double sum = n * ((start + end) / 2);
  57.  
  58. Label4.Text = "The sum is " + sum;
  59. }
  60. else if (start > end)
  61. {
  62. MessageBox.Show("Error: The start has to be less than the end.");
  63. }
  64. }
  65. }
  66.  
  67. private void button3_Click(object sender, EventArgs e)
  68. {
  69. TextBox1.Text = "";
  70. TextBox2.Text = "";
  71. Label3.Text = "BMI: ";
  72. }
  73.  
  74. private void button4_Click(object sender, EventArgs e)
  75. {
  76. TextBox3.Text = "";
  77. TextBox4.Text = "";
  78. Label4.Text = "Sum: ";
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement