I'm making a Gym Application that calculates the cost of their membership and discount they are given depending on which duration they choose (3 months, 12 months, 24 months) .

I am stuck on the discount part of the code because the last "totaldiscount" is coming up as an error saying it isn't an assigned variable.

I have tried a few ways by changing the if statement to a case statement, ive also tried to change int to float and still hasn't worked.

           {

                int discountprice;

                if (Basicradiobt.Checked) 
                {
                    discountprice = 0;
                    discountprice *= 0;
                }
                else if (Regularradiobt.Checked)
                {
                    discountprice = 2;
                    discountprice *= 2;
                }
                else if (Premiumradionbt.Checked)
                {
                    discountprice = 5;
                    discountprice *= 5;
                }
                Totaldiscounttxtbx.Text = membershipcost + extracost - discountprice.ToString();

            }

I expect when the user selects which duration they want (3 month, 12 month, 24 month) that the code takes the discount depending on the duration and takes it off their final membership cost that includes the type and any extras added. Id appreciate any help ive been stuck on this for a least a week.

0 Answers