mardi 15 mai 2018

Simple Condition (Windows Forms Application) C#

I created the application called simpleCondition. This program is to show the user select on the checkbox button either food , drinks and both.

    private void btnSelect_Click(object sender, EventArgs e)
    {
        if (chkbxFood.Checked == true)
        {
            price = 15.00;
            lblOutput.Text = "Food is selected";
            tbxOutput.AppendText("Total Price " + price + Environment.NewLine);
        }
        else if (chkbxDrink.Checked == true)
        {
            price = 2.00;
            lblOutput.Text = "Drink is selected";
            tbxOutput.AppendText("Total Price " + price + Environment.NewLine);
        }
        if(chkbxFood.Checked && chkbxDrink.Checked)
        {
            price = 17.00;
            lblOutput.Text = "Food and Drink are selected";
            tbxOutput.AppendText("Total Price " + price + Environment.NewLine);
        }
    }

So, i want to make the program if the user select the food, it shows the food is selected or the user can select the drink, it shows the drinks is selected. Lastly, if the user click on both, it shows the food and drinks are selected.

But, this program is already correct if user only click either food and drinks. also the price is already correct. then if the user click both on the checkedBoxes, it shows the food price is 15 and the second one is the total price is 17.00

I hope you can help me to clarify this program!

Thanks

Aucun commentaire:

Enregistrer un commentaire