Advertisement
aaronvan

Check-Box Order-of-Operation

May 20th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.81 KB | None | 0 0
  1.         const double TaxRate = 0.0775;
  2.         static double subtotal;
  3.         static double tax;
  4.         static double OrderTotal;
  5.  
  6.         private void radButtonHamburger_CheckedChanged(object sender, EventArgs e)
  7.         {
  8.             subtotal = 0.0;
  9.             txtSubtotal.Clear();
  10.            
  11.             lblAddOnItems0.Text = "Lettuce, tomato, and onions";
  12.             lblAddOnItems1.Text = "Ketchup, mustard, an mayo";
  13.             lblAddOnItems2.Text = "French fries";
  14.             grpBoxAddOnItems.Text = "Add-on items($.75/each)";
  15.  
  16.             /* add the extra items */
  17.             if (chkBox0.Checked)
  18.                 subtotal += 0.75;
  19.             if (chkBox1.Checked)
  20.                 subtotal += 0.75;
  21.             if (chkBox2.Checked)
  22.                 subtotal += 0.75;
  23.  
  24.             subtotal += 6.95; // main course
  25.             tax = (subtotal * TaxRate);
  26.             OrderTotal = subtotal + tax;
  27.         }
  28.  
  29.         private void radButtonPizza_CheckedChanged(object sender, EventArgs e)
  30.         {
  31.             subtotal = 0.0;
  32.             txtSubtotal.Clear();
  33.            
  34.             lblAddOnItems0.Text = "Pepperoni";
  35.             lblAddOnItems1.Text = "Sausage";
  36.             lblAddOnItems2.Text = "Olives";
  37.             grpBoxAddOnItems.Text = "Add-on items($.50/each)";
  38.  
  39.             /* add the extra items */
  40.             if (chkBox0.Checked)
  41.                 subtotal += 0.50;
  42.             if (chkBox1.Checked)
  43.                 subtotal += 0.50;
  44.             if (chkBox2.Checked)
  45.                 subtotal += 0.50;
  46.  
  47.             subtotal += 5.95; // main course
  48.             tax = (subtotal * TaxRate);
  49.             OrderTotal = subtotal + tax;
  50.         }
  51.  
  52.         private void radButtonSalad_CheckedChanged(object sender, EventArgs e)
  53.         {
  54.             subtotal = 0.0;
  55.             txtSubtotal.Clear();
  56.            
  57.             lblAddOnItems0.Text = "Croutouns";
  58.             lblAddOnItems1.Text = "Bacon bits";
  59.             lblAddOnItems2.Text = "Bread sticks";
  60.             grpBoxAddOnItems.Text = "Add-on items($.25/each)";
  61.            
  62.             /* add the extra items */
  63.             if (chkBox0.Checked)
  64.                 subtotal += 0.25;
  65.             if (chkBox1.Checked)
  66.                 subtotal += 0.25;
  67.             if (chkBox2.Checked)
  68.                 subtotal += 0.25;
  69.  
  70.             subtotal += 4.95; // main course
  71.             tax = (subtotal * TaxRate);
  72.             OrderTotal = subtotal + tax;
  73.         }
  74.  
  75.         private void btnPlaceOrder_Click(object sender, EventArgs e)
  76.         {
  77.             txtSubtotal.Text = subtotal.ToString("C2");
  78.             txtTax.Text = tax.ToString("C2");
  79.             txtOrderTotal.Text = OrderTotal.ToString("C2");
  80.         }
  81.  
  82.         private void btnExit_Click(object sender, EventArgs e)
  83.         {
  84.             Application.Exit();
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement