Advertisement
farahfresnido

HOA4??

Jan 23rd, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. FARAH FRESNIDO HOA4
  2.  
  3. TO DO LIST !:
  4. * work on design frame on that comp
  5. * do groupbox control
  6. * change messagebox to label 3 & put formula there !
  7. * click on button1 first before copy pasting codes
  8. * why doesnt it work when not both fields are filled up ? work on that.
  9.  
  10. public partial class MainWindow : Window
  11. {
  12. public MainWindow()
  13. {
  14. InitializeComponent();
  15. }
  16.  
  17.  
  18. private void Button1_Click(object sender, RoutedEventArgs e)
  19. {
  20. double weight = double.Parse(Textbox1.Text);
  21. double height = double.Parse(Textbox2.Text);
  22.  
  23. if ((Textbox1.Text == "" || Textbox2.Text == "") || (Textbox1.Text == "" && Textbox2.Text == ""))
  24. {
  25. MessageBox.Show("Error: Don't leave anything blank.");
  26. }
  27. else if (Textbox1.Text != "" && Textbox2.Text != "")
  28. {
  29. double BMI = (weight * 0.45) / ((height * 0.025) * (height * 0.025));
  30. MessageBox.Show("BMI: " + BMI);
  31.  
  32. Textbox1.Text = "";
  33. Textbox2.Text = "";
  34. }
  35. }
  36.  
  37. private void Button1a_Click(object sender, RoutedEventArgs e)
  38. {
  39. double start = double.Parse(Textbox1a.Text);
  40. double end = double.Parse(Textbox2a.Text);
  41.  
  42. if ((Textbox1a.Text == "" || Textbox2a.Text == "") || (Textbox1a.Text == "" && Textbox2a.Text == ""))
  43. {
  44. MessageBox.Show("Error: Don't leave anything blank.");
  45. }
  46. else if (Textbox1a.Text != "" && Textbox2a.Text != "")
  47. {
  48. if (end < start)
  49. {
  50. MessageBox.Show("Error: Starting value has to be less than the ending value.");
  51. }
  52. else if (end > start)
  53. {
  54. double n = end - start + 1;
  55. double sum = n * ((end + start) / 2);
  56.  
  57. MessageBox.Show("Sum: " + sum);
  58.  
  59. Textbox1a.Text = "";
  60. Textbox2a.Text = "";
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement