samedi 18 janvier 2020

Calculating Total with Radiobuttons and CheckBoxes

I'm trying to calculate a total based on inputs from checkboxes and radiobuttons.

The goals are:

  1. to calculate the total based on the size, toppings and quantity
  2. to display the total once the user select Submit Order in another message box.

I am unable to post a photo of my form but the sizes are radio options and toppings are checkboxes. The quantity is a textbox.

private void submitBtn_Click(object sender, EventArgs e)
        {  
            //set price of size and toppings
            double smallPizza = 10.00;
            double mediumPizza = 15.00;
            double largePizza = 15.00;
            double pepTop = 00.50;
            double sausTop = 00.50;
            double oliveTop = 00.50;
            double onionTop = 00.50;
            double xcheeseTop = 00.50;
            double total = 0;
            double tax = .6;
            double subTotal = 0;
            //parse quantity textbox
            int valid = int.Parse(quantityTxt.Text);

            //how to calculate quantity and sizes toppings? 

            //calculate total
            subTotal = tax + total;
            //create message box with order details and subtotal
            string title = "Order Submit Confirmation";
            string message = "Thank you for placing an order with us!"
                + "You ordered" + "" + "Your total is: $" + subTotal;
            //show message box
            MessageBox.Show(message, title);
        }



Aucun commentaire:

Enregistrer un commentaire