Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. class Prices
  2. {
  3. public const double blackink = 0.45;
  4. public const double redink = 0.50;
  5. public const double bluewb = 1.20;
  6. public const double blackwb = 1.10;
  7. public const double a4 = 2.50;
  8.  
  9. }
  10. protected void btnPurchase_Click(object sender, EventArgs e)
  11. {
  12. // Variables
  13. double blackink, redink, bluewb, blackwb, a4, total1, total2, total3, total4, total5, overallTotal;
  14.  
  15. string name, address1, address2, postCode;
  16.  
  17. // Assigning Variables
  18. name = txtName.Text;
  19.  
  20. address1 = txtAddress1.Text;
  21.  
  22. address2 = txtAddress2.Text;
  23.  
  24. postCode = txtpostCode.Text;
  25.  
  26. // Conversion
  27. blackink = Convert.ToDouble(txtBlackInk.Text);
  28.  
  29. redink = Convert.ToDouble(txtRedInk.Text);
  30.  
  31. bluewb = Convert.ToDouble(txtBlueWB.Text);
  32.  
  33. blackwb = Convert.ToDouble(txtBlackWB.Text);
  34.  
  35. a4 = Convert.ToDouble(txtA4.Text);
  36.  
  37. // If Statement - Black Ink pen
  38. if (blackink == 0)
  39. {
  40. total1 = 0;
  41. }
  42. else
  43. {
  44. total1 = blackink * Prices.blackink;
  45. }//end
  46.  
  47. // If Statement - Red Ink pen
  48. if (redink == 0)
  49. {
  50. total2 = 0;
  51. }
  52. else
  53. {
  54. total2 = redink * Prices.redink;
  55. }//end
  56.  
  57. // If Statement - Blue Whiteboard marker
  58. if (bluewb == 0)
  59. {
  60. total3 = 0;
  61. }
  62. else
  63. {
  64. total3 = bluewb * Prices.bluewb;
  65. }//end
  66.  
  67. // If Statement - Black Whiteboard marker
  68. if (blackwb == 0)
  69. {
  70. total4 = 0;
  71. }
  72. else
  73. {
  74. total4 = blackwb * Prices.blackwb;
  75. }//end
  76.  
  77. // If Statement - A4
  78. if (a4 == 0)
  79. {
  80. total5 = 0;
  81. }
  82. else
  83. {
  84. total5 = a4 * Prices.a4;
  85. }//end
  86.  
  87. overallTotal = total1 + total2 + total3 + total4 + total5;
  88.  
  89. if (overallTotal > 50.00)
  90. {
  91. lblPrice.Text = "You recieved a 5% discount, your overall total is £" + overallTotal * 0.95;
  92. }
  93. else
  94. {
  95. lblPrice.Text = "Your overall total is £" + overallTotal;
  96. };
  97.  
  98.  
  99.  
  100. lblCusName.Text = "Thank you, " + name;
  101. lblDelivery.Text = "Your stationery items will be sent to " + address1 + ", " + address2 + ". " + postCode;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement