我在数学上做错了什么?

时间:2014-12-13 02:13:57

标签: c# math if-statement mathprog

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"));

当我输入就业状态为“FULL”并且工会状态为“MEMBER”时,销售数量为“100”,年份为“25”。每周的工资额应为“783.30美元”。但我最终获得667.59美元作为输出。我看不出我做错了什么。

以下是必须遵循的准则:

全职代表每周工作40小时,每小时20美元 兼职代表每周工作20小时,每小时10.00美元 一些代表属于工会,每周支付5.25美元的工会会费 如果代表工作了10年或更长时间,他们将获得10%的销售佣金,否则他们将获得5%的销售佣金 小部件的售价为9.25美元 如果全职工人的销售额超过其基本工资的80%,则他们有权获得5%的销售额奖金 所有代表根据其总收入支付16%的FICA税

P.S。我知道这是很多阅读,但如果你可以帮助我,这对我来说就像是一个圣诞奇迹。

2 个答案:

答案 0 :(得分:1)

根据工会会费计算你的计算结果......
显然,要获得783.30的工资,工会会费将在FICA税收适用后扣除...

 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"));
}

答案 1 :(得分:0)

根据我的计算,783.30的值是错误的。手工做数学:

(800(基数) - 5.25(联盟)+ 92.5(佣金)+ 46.25(奖金))*。84(税)= 784.14。除非支付的确定与您提到的指南不同,否则您的程序运行正常且旧程序错误。