Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

salary, overtime, deductions, gross pay and netpay in console C#

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string empName;
            string userInput;

            double netPay;
            double editedTax1;
            double grossPay;
            double editedTax2;
            double hrsWorked;
            double ovtWorked;
            double payRate;

            const double FED_TAX = .28;
            const double SS_TAX = 7.65;




            // step 1
            Console.WriteLine("       WEEKLY PAYROLL INFORMATION");

            // step 2
            Console.WriteLine("       --------------------------");

            // step 3
            Console.Write("
       Please enter the employer's name: ");
            empName = Console.ReadLine();

            //step 4
            Console.Write("
       Please enter the number of hours worked this week: ");
            userInput = Console.ReadLine();
            hrsWorked = Convert.ToDouble(userInput);

            // step 5
            Console.Write("
       Please enter the number of OVERTIME HOURS worked this week: ");
            userInput = Console.ReadLine();
            ovtWorked = Convert.ToInt32(userInput);

            // step 6
            Console.Write("
       Please enter employee's HOURLY PAY RATE: ");
            userInput = Console.ReadLine();
            payRate = Convert.ToDouble(userInput);

            // step 7
            grossPay = (hrsWorked * payRate + ovtWorked * 1.5 * payRate);

            // step 8
            editedTax1 = FED_TAX * grossPay;

            // step 9
            editedTax2 = SS_TAX * grossPay;

            // step 10
            netPay = editedTax1 + editedTax2 - grossPay;

            // step 11
            Console.WriteLine("

       The weekly payroll information summary for: " + empName);

            Console.WriteLine("
       Gross pay:                             {0:C2}    ", grossPay);

            // step 12
            Console.WriteLine("       Federal income taxes witheld:          {0:C2}      ", editedTax1);
            Console.WriteLine("       Social Security taxes witheld:         {0:C2}    ", editedTax2);
            Console.WriteLine("       Net Pay:                               {0:C2}", netPay);


        }
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #gross #pay #netpay #console
ADD COMMENT
Topic
Name
1+9 =