What am i doing wrong with the math?

96 views Asked by At

private void btnDisplay_Click(object sender, EventArgs e)

    {
        string EmploymentStatus = Convert.ToString(txtES.Text).ToLower();
        string UnionStatus = Convert.ToString(txtMS.Text).ToLower();
        double TotalSales = Convert.ToDouble(txtSales.Text) * 9.25;
        double Years = Convert.ToDouble(txtYears.Text);         
        double uniondues;
        double FICA = 0;
        double bonus = 0;
        double WPay = 0;
        double TotalComission = 0;

        if (EmploymentStatus == "full")
        {                 
            WPay = 800.00;
        }
        else if (EmploymentStatus == "part")
        {
            WPay = 200.00;
        }
        else
        {
            MessageBox.Show("Error, please enter either FULL or PART");
        }

            if (UnionStatus == "member")
            {
                uniondues = 5.25;
                WPay = WPay - uniondues;
            }
            else if (UnionStatus == "non-member")
            {
                uniondues = 0;
            }
            else
            {
                MessageBox.Show("Error, please enter either MEMBER or NON-MEMBER");
            }
            if ((EmploymentStatus == "full") && (TotalSales > 640))
            {
                bonus = TotalSales * .05;

            }
            else if (EmploymentStatus == "part")
            {
                bonus = 0;
            }
            if (Years >= 10)
            {
                TotalComission = TotalSales * .10;

            }
            else if (Years < 10)
            {
                TotalComission = TotalSales * .05;

            }
            else
            {
                MessageBox.Show("Error, please enter a valid number");
            }


            FICA = WPay * .16;
            WPay = WPay - FICA;


        lblqWPay.Text = "The weekly pay for the employee is: " + (WPay.ToString("C"));
        lblqTS.Text = "The total sales for this employee is: " + (TotalSales.ToString("C"));
        lblqCom.Text = "The comission for this employee is: " + (TotalComission.ToString("C"));
        lblqBonus.Text = "The bonus for this employee is: " + (bonus.ToString("C"));

When i enter the employment status as "FULL" and union status as "MEMBER", with the quantity sold as "100", and the years employed as "25". The weekly pay output should be "$783.30". But i end up getting $667.59 as the output. I cannot see what i am doing wrong.

Here are the guidelines that have to follow:

Full time representatives work 40 hours per week at a rate of $20.00 per hour Part time representatives work 20 hours per week at a rate of $10.00 per hour Some representatives belong to the union and pay $5.25 each week in union dues If the representative has worked 10 years or more they get a commission of 10% of sales, otherwise they get a commission of 5% of sales Widgets sell for $9.25 If a full time worker has sales that are more than 80% of their base pay they are entitled to a bonus of 5% of their sales All representatives pay a 16% FICA tax based on their total earnings

P.S. I know this is a lot of reading, but if you can help me with this, it would be like a Christmas miracle to me.

2

There are 2 answers

2
DRapp On BEST ANSWER

Your computation is off based on the union dues...
Apparently, to get the 783.30 pay, the union dues are deducted AFTER the FICA tax has been applied...

 800.00 (base) 
+ 46.25 (5% bonus when over 80% base) 
+ 92.50 (10% commission on 925 sales)
=======
 938.75
-150.20 (16% FICA)
=======
 788.55 Net pay before union dues
-  5.25 (union) 
=======
 783.30

private void btnDisplay_Click(object sender, EventArgs e)
{
   string EmploymentStatus = Convert.ToString(txtES.Text).ToLower();
   string UnionStatus = Convert.ToString(txtMS.Text).ToLower();
   double TotalSales = Convert.ToDouble(txtSales.Text) * 9.25;
   double Years = Convert.ToDouble(txtYears.Text);         
   double uniondues = 0;
   double FICA = 0;
   double bonus = 0;
   double WPay = 0;
   double TotalComission = 0;


   if (EmploymentStatus == "full")
   {
      WPay = 800.00;
      // since already in full-time status check, compute bonus here now.
      // based on 80% of base pay
      if (TotalSales > WPay * .80)
         bonus = TotalSales * .05;
   }
   else if (EmploymentStatus == "part")
      WPay = 200.00;
   else
      MessageBox.Show("Error, please enter either FULL or PART");

   // Only if qualified full/part time status
   if( WPay > 0 )
   {
      if (UnionStatus == "member")
         uniondues = 5.25;
      else if (UnionStatus == "non-member")
         uniondues = 0;
      else
         MessageBox.Show("Error, please enter either MEMBER or NON-MEMBER");

      if (Years >= 10)
         TotalComission = TotalSales * .10;
      else if (Years < 10)
         TotalComission = TotalSales * .05;
      else
         MessageBox.Show("Error, please enter a valid number");


      // NOW, build out the total pay before computing FICA
      WPay = WPay + bonus + TotalComission;

      // NOW Compute FICA
      FICA = WPay * .16;

      // and remove FICA and Union dues from gross pay to get net pay
      WPay = WPay - FICA - uniondues;
   }

   lblqWPay.Text = "The weekly pay for the employee is: " + (WPay.ToString("C"));
   lblqTS.Text = "The total sales for this employee is: " + (TotalSales.ToString("C"));
   lblqCom.Text = "The comission for this employee is: " + (TotalComission.ToString("C"));
   lblqBonus.Text = "The bonus for this employee is: " + (bonus.ToString("C"));
}
0
Erik Remkus On

The value of 783.30 is wrong by my calculations. Doing the math by hand:

(800 (base) - 5.25 (union) + 92.5 (commision) + 46.25 (bonus))*.84 (tax) = 784.14. Unless the pay is determined differently from the guides you have mentioned your program is running correctly and the old one was wrong.