Advertisement
DevUModerator

Untitled

Jul 4th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. protected void Page_Load( object sender, EventArgs e )
  2. {
  3.  
  4. }
  5.  
  6. protected void groundRadioButton_CheckedChanged( object sender, EventArgs e )
  7. {
  8. performCalculation();
  9. }
  10.  
  11. protected void airMailRadioButton_CheckedChanged( object sender, EventArgs e )
  12. {
  13. performCalculation();
  14. }
  15.  
  16. protected void nextDayRadioButton_CheckedChanged( object sender, EventArgs e )
  17. {
  18. performCalculation();
  19. }
  20.  
  21.  
  22.  
  23. private void performCalculation()
  24. {
  25. //Are there values put in the textboxes?
  26. if (widthTextBox.Text.Trim().Length == 0 && heightTextBox.Text.Trim().Length == 0) return;
  27.  
  28. //Is a shipping method selected?
  29. if (!groundRadioButton.Checked && !airMailRadioButton.Checked && !nextDayRadioButton.Checked) return;
  30.  
  31. //get the values out of the 2 text boxes
  32. int width = int.Parse(widthTextBox.Text);
  33. int height = int.Parse(heightTextBox.Text);
  34.  
  35. //get the volume of package
  36. double volume = width * height;
  37.  
  38. double totalCost = doingMath(volume);
  39.  
  40. printResults(totalCost);
  41. }
  42.  
  43.  
  44. private double doingMath( double volume )
  45. {
  46. //figure out the total cost of shipping by using the shipping multiplier provided by Bob
  47. double totalCost = 0.0;
  48. if (groundRadioButton.Checked) totalCost = volume * .15;
  49. else if (airMailRadioButton.Checked) totalCost = volume * .25;
  50. else if (nextDayRadioButton.Checked) totalCost = volume * .45;
  51. else totalCost = 0.0;
  52. return totalCost;
  53. }
  54. private void printResults( double totalCost )
  55. {
  56. //print out the final result
  57. resultLabel.Text = String.Format("The Total Cost is: {0:C}", totalCost);
  58. }
  59.  
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement