riggnaros

johns project

Nov 29th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.52 KB | None | 0 0
  1. //CalculateCosts - This function calculates the costs of the smoothie.
  2.         private void CalculateCosts()
  3.         {
  4.  
  5.             //--------------------------------
  6.             //--------------------------------
  7.             //Declare variables
  8.             //--------------------------------
  9.             //--------------------------------
  10.  
  11.             //Declare my smoothie prices.   Column 0      1      2      3
  12.             decimal[,] smoothieListDecimal = { { 5.99M, 6.99M, 7.99M, 8.99M },    // Row 0
  13.                                                { 6.99M, 7.99M, 8.99M, 9.99M } };  // Row 1
  14.  
  15.             //Delcare the variable "extras" for the cost of extras.
  16.             //I'm just gonna use one variable since all of the extras are the same price.
  17.             const decimal extras = 0.75M;
  18.  
  19.             //Declare the variables for the discounts.
  20.             const decimal preferred = 0.15M;
  21.             const decimal coupon = 0.10M;
  22.             decimal discount;
  23.  
  24.             //Declare the variable for quantity.
  25.             int quantity;
  26.  
  27.             //Declare the count for the extras.
  28.             int numberOfExtras = 0;
  29.  
  30.             //Declare the cost of the smoothie.
  31.             decimal smoothieCost = 0.00M;
  32. //--------------------------------
  33.             //--------------------------------
  34.             //Verify entries
  35.             //--------------------------------
  36.             //--------------------------------
  37.  
  38.             //Check to make sure the customer name is filled.
  39.             if (customerTextBox.Text == "")
  40.             {
  41.                 MessageBox.Show("Please enter the customer name");
  42.             }
  43.  
  44.             //Check to make sure a size is selected.
  45.             if (sizeComboBox.SelectedIndex == -1)
  46.             {
  47.                 MessageBox.Show("Please select a smoothie size");
  48.             }
  49.  
  50.             //Check to make sure a style is selected.
  51.             if (styleComboBox.SelectedIndex == -1)
  52.             {
  53.                 MessageBox.Show("Please select a smoothie style");
  54.             }
  55.  
  56.             //Check the quantity entry.
  57.             if (int.TryParse(quantityTextBox.Text, out quantity) && quantity > 0)
  58.             {
  59.                 //Do nothing since I'm just confirming something is entered.
  60.             }
  61.             else
  62.             {
  63.                 MessageBox.Show("Please enter a whole numeric quantity");
  64.             }
  65. //--------------------------------
  66.             //--------------------------------
  67.             //Gather Information
  68.             //--------------------------------
  69.             //--------------------------------
  70.  
  71.             //If Echinacea is checked, add 1 extra to the bill.
  72.             if (echinaceaCheckBox.Checked == true)
  73.             {
  74.                 numberOfExtras++;
  75.             }
  76.  
  77.             //If Bee Pollen is checked, add 1 extra to the bill.
  78.             if (beePollenCheckBox.Checked == true)
  79.             {
  80.                 numberOfExtras++;
  81.             }
  82.  
  83.             //If Energy Booster is checked, add 1 extra to the bill.
  84.             if (energyBoosterCheckBox.Checked == true)
  85.             {
  86.                 numberOfExtras++;
  87.             }
  88.  
  89.             //If Preferred is checked, set the the discount to 15%.
  90.             if (preferredRadioButton.Checked == true)
  91.             {
  92.                 discount = preferred;
  93.             }
  94.  
  95.             //If Coupon is checked, set the discount to 10%.
  96.             if (couponRadioButton.Checked == true)
  97.             {
  98.                 discount = coupon;
  99.             }
  100.  
  101.  
  102.  
  103.         }
Advertisement
Add Comment
Please, Sign In to add comment