Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CalculateCosts - This function calculates the costs of the smoothie.
- private void CalculateCosts()
- {
- //--------------------------------
- //--------------------------------
- //Declare variables
- //--------------------------------
- //--------------------------------
- //Declare my smoothie prices. Column 0 1 2 3
- decimal[,] smoothieListDecimal = { { 5.99M, 6.99M, 7.99M, 8.99M }, // Row 0
- { 6.99M, 7.99M, 8.99M, 9.99M } }; // Row 1
- //Delcare the variable "extras" for the cost of extras.
- //I'm just gonna use one variable since all of the extras are the same price.
- const decimal extras = 0.75M;
- //Declare the variables for the discounts.
- const decimal preferred = 0.15M;
- const decimal coupon = 0.10M;
- decimal discount;
- //Declare the variable for quantity.
- int quantity;
- //Declare the count for the extras.
- int numberOfExtras = 0;
- //Declare the cost of the smoothie.
- decimal smoothieCost = 0.00M;
- //--------------------------------
- //--------------------------------
- //Verify entries
- //--------------------------------
- //--------------------------------
- //Check to make sure the customer name is filled.
- if (customerTextBox.Text == "")
- {
- MessageBox.Show("Please enter the customer name");
- }
- //Check to make sure a size is selected.
- if (sizeComboBox.SelectedIndex == -1)
- {
- MessageBox.Show("Please select a smoothie size");
- }
- //Check to make sure a style is selected.
- if (styleComboBox.SelectedIndex == -1)
- {
- MessageBox.Show("Please select a smoothie style");
- }
- //Check the quantity entry.
- if (int.TryParse(quantityTextBox.Text, out quantity) && quantity > 0)
- {
- //Do nothing since I'm just confirming something is entered.
- }
- else
- {
- MessageBox.Show("Please enter a whole numeric quantity");
- }
- //--------------------------------
- //--------------------------------
- //Gather Information
- //--------------------------------
- //--------------------------------
- //If Echinacea is checked, add 1 extra to the bill.
- if (echinaceaCheckBox.Checked == true)
- {
- numberOfExtras++;
- }
- //If Bee Pollen is checked, add 1 extra to the bill.
- if (beePollenCheckBox.Checked == true)
- {
- numberOfExtras++;
- }
- //If Energy Booster is checked, add 1 extra to the bill.
- if (energyBoosterCheckBox.Checked == true)
- {
- numberOfExtras++;
- }
- //If Preferred is checked, set the the discount to 15%.
- if (preferredRadioButton.Checked == true)
- {
- discount = preferred;
- }
- //If Coupon is checked, set the discount to 10%.
- if (couponRadioButton.Checked == true)
- {
- discount = coupon;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment