Prime b

Prime b

  • NA
  • 810
  • 339k

payroll

Dec 31 2011 1:08 PM
Hey guys, this is the problem
Write a console-based program that prompts the user for
an hourly pay rate and hours worked. Compute gross pay
(hours times pay rate), withholding tax, and net pay (gross
pay minus withholding tax). Withholding tax is computed
as a percentage of gross pay based on the following:
Gross Pay Withholding Percentage
Up to and including 300.00= 10%
300.01 and up = 12%




Thats what i have done

            double hPayRate, hWorked, grossPay, wthHoldTax, netPay;
            string stringhPayRate, stringhWorked;


            Console.WriteLine(" Please enter your hourly pay rate ");
            stringhPayRate = Console.ReadLine();
            hPayRate = Convert.ToDouble(stringhPayRate);

            Console.WriteLine(" Please enter how many hours you worked ");
            stringhWorked = Console.ReadLine();
            hWorked = Convert.ToDouble(stringhWorked);

            grossPay = hPayRate * hWorked;

            if (grossPay <= 300.00)
            {

                wthHoldTax = grossPay * .10;
                netPay = grossPay - wthHoldTax;
                Console.WriteLine(" Your net pay is {0}", netPay);
            }
            else  if (grossPay >= 300.01)

            {
                wthHoldTax = grossPay * .12;
                netPay = grossPay - wthHoldTax;
                Console.WriteLine(" Your net pay is {0}", netPay);
            }

Any other cool alternative ways to solve this problem?


Answers (4)