dimanche 3 mars 2019

Radiobutton in usage in btnClicked

I made the following assignment to calculate contribution depending which sport you play. If I run the code I get a -180 as a result which I dont understand. Here's the code:

const double Football = 175; const double Handball = 225;

    private void btnCalculateFee_Click(object sender, EventArgs e)
    {
        int Age = int.Parse(AgeInput.Text);
        int Mem = int.Parse(MembershipInput.Text);

        double MemDiscF = Football - 20;
        double AgeDiscF = Football - 25;
        double MemAgeDiscF = Football - (MemDiscF + AgeDiscF);

        if (rbtnFootball.Checked == true && Age < 40 && Mem < 10)
        {
            lblFeePrint.Text = Football.ToString();
        }
        else if (rbtnFootball.Checked == true && Age < 40 && Mem > 10)
        {
            lblFeePrint.Text = MemDiscF.ToString();
        }
        else if (rbtnFootball.Checked == true && Age > 40 && Mem < 10)
        {
            lblFeePrint.Text = AgeDiscF.ToString();
        }
        else 
        {
            lblFeePrint.Text = MemAgeDiscF.ToString();
        }

        double MemDischM = Handball - 20;
        double AgeDiscM = Handball - 25;
        double MemAgeDiscM = Handball - (MemDischM + AgeDiscM);

        if (rbtnHandball.Checked == true && Age < 40 && Mem < 10)
        {
            lblFeePrint.Text = Handball.ToString("0.00");
        }
        else if (rbtnHandball.Checked == true && Age < 40 && Mem > 10)
        {
            lblFeePrint.Text = MemDischM.ToString("0,00");
        }
        else if (rbtnHandball.Checked == true && Age > 40 && Mem < 10)
        {
            lblFeePrint.Text = AgeDiscM.ToString("0,00");
        }
        else
        {
            lblFeePrint.Text = MemAgeDiscM.ToString("0,00");
        }
    }

Aucun commentaire:

Enregistrer un commentaire