Question

Design and code a project to calculate the amount due for Geoff’s Smoothie Shop. He needs...

Design and code a project to calculate the amount due for Geoff’s Smoothie Shop. He needs a program that will calculate the price for each individual order as well as a summary for all orders.

1. The store employees will enter the orders into an order form that has a text box for quantity and radio buttons to select their size.
2. On the form display the current selection order (price of item * quantity) and current customer total (combined total of everything that the customer purchased) in labels or read-only text boxes.
Note: A customer can order multiple, different items on one order.
3. Include buttons for:
a. Calculate the selection
b. Clear for next item
c. Summary (display in a Message Box)
d. New Customer (starts a new customer's order)
e. Exit
4. Quantity must be verified using a Try/Catch statement. If the quantity is invalid, do not perform any calculations, but display a message box and allow the user to fix the correct the quantity.
5. Prices of sizes for calculations (Small- $3.75, Medium - $5, Large - $5.75, XL - $6.50)
6. Include checkboxes for each of the following fruit to be added to the smoothie. (Mango $.70, Banana $.45, Strawberry $.50, Blueberries $.50, Kiwi $.75, Blackberry $.80, Raspberry $.75)
7. The New Customer menu item will ask to clear the current order figures with a yes/no message box. If the user says yes, then it will clear and a new order can be started.
8. The summary message box will display the grand total sales of ALL orders and the total number of customers.

Homework Answers

Answer #1

Hi,

This has been developed in the C# Windows Form.

Please find the output:

Please find the below code:

using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OrdersCalculationShop
{
    public partial class Form1 : Form
    {
        //Gloabl counter for summary 
        double dUserTotalAmount = 00.00;
        double iTotalCustomerCount = 0;
        double iTotalOrder = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btnCalculateSelection_Click(object sender, EventArgs e)
        {
            
            int iQuantity;
            bool bIsValid = true;

            //Get the Quantity text value enererd by user
            //This is numeric text box
            bool b = Int32.TryParse(txtQuantity.Value.ToString().Trim(), out iQuantity);

            //If quantity is not selected then propmt the user
            if (iQuantity <= 0)
            {
                MessageBox.Show("Quantiy should be greater than 0.");
                bIsValid = false;
            }

            //Calculate the Price of Item
            double dPriceOfItem = 00.00;
            bool bIsSizeSelected = false;
            if (rbtnSmall.Checked)
            {
                dPriceOfItem = 3.75;
                bIsSizeSelected = true;
            }
            else if (rbtnMedium.Checked)
            {
                dPriceOfItem = 5;
                bIsSizeSelected = true;
            }
            else if (rbtnLarge.Checked)
            {
                dPriceOfItem = 5.75;
                bIsSizeSelected = true;
            }
            else if (rbtnXL.Checked)
            {
                dPriceOfItem = 6.50;
                bIsSizeSelected = true;
            }

            //If size is not selected then prompt message
            if (!bIsSizeSelected) {
                MessageBox.Show("Pleas select size");
                bIsValid = false;
            }

            //Calculate the smoothie checked by user
            //add total price by each selection
            double dSmoothieAmount = 00.00;
            if (chkMango.Checked)
            {
                dSmoothieAmount += 0.70;
            }
            if (chkBanana.Checked)
            {
                dSmoothieAmount += 0.45;
            }
            if (chkStrawberry.Checked)
            {
                dSmoothieAmount += 0.50;
            }
            if (chkBlueberries.Checked)
            {
                dSmoothieAmount += 0.50;
            }
            if (chkKiwi.Checked)
            {
                dSmoothieAmount += 0.75;
            }
            if (chkBlackberry.Checked)
            {
                dSmoothieAmount += 0.80;
            }
            if (chkRaspberry.Checked)
            {
                dSmoothieAmount += 0.75;
            }

            //Check here all he validation and then only do the calculation in the summary
            if (bIsValid) {
                //Upate the Total Order Counters
                iTotalOrder += 1;

                //Calculate the selction of user prices
                string sMessageOrderDetails = string.Empty;
                double dOrderTotal = (iQuantity * dPriceOfItem) + dSmoothieAmount;

                //Update the summary
                dUserTotalAmount = dUserTotalAmount + dOrderTotal;
                richTextSummary.Text = "Total number of Order is - " + iTotalOrder + "\r\n" +
                        "Grand Total Sales is -" + dUserTotalAmount;

                //UPdate the flag
                bIsValid = false;

                //Update the Quantity to 0
                txtQuantity.Value = 0;

            }
            

        }

        /// <summary>
        /// Clear the Controls
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClear_Click(object sender, EventArgs e)
        {
            //Call metod who clears all the controls
            ClearControls();
        }

        /// <summary>
        /// Clear control mehods
        /// </summary>
        private void ClearControls() {
            txtQuantity.ResetText();
            chkBanana.Checked = false;
            chkBlackberry.Checked = false;
            chkBlueberries.Checked = false;
            chkKiwi.Checked = false;
            chkMango.Checked = false;
            chkRaspberry.Checked = false;
            chkStrawberry.Checked = false;
            rbtnLarge.Checked = false;
            rbtnMedium.Checked = false;
            rbtnSmall.Checked = false;
            rbtnXL.Checked = false;
        }

        /// <summary>
        /// Btton New Customer Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNewCustomer_Click(object sender, EventArgs e)
        {
            //Prompt user to ask the Y or N to proceed
            string sCreatenewOrder = Interaction.InputBox("Please Enter - Y for Create New Customer and N for Cancel", "New Order", "Y");
            if (sCreatenewOrder == "Y" || sCreatenewOrder == "y")
            {
                //If user enrered the Y or y then clear controls
                ClearControls();

                //Update the summary
                richTextSummary.Text =  "Total number of Order is - " + iTotalOrder + "\r\n" +
                    "Grand Total Sales is -" + dUserTotalAmount;

                
            }
        }

        /// <summary>
        /// Exit the application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void rbtnSmall_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void rbtnMedium_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void rbtnLarge_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void rbtnXL_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}

Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions