Search
 
SCRIPT & CODE EXAMPLE
 

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


        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# regex double of some letters only 
Csharp :: string with starting zero to int c# 
Csharp :: C# string array in setter 
Csharp :: how to make a console feedback 
Csharp :: copy array to array in c# 
Csharp :: how to check that a gameobject touches a colour in unity c# 
Csharp :: c# inject dll into process 
Csharp :: Debug output to console and a log 
Csharp :: material Array setter 
Csharp :: tmpro pageCount update 
Csharp :: c# increment by 2 
Csharp :: c# create monochrome bitmap 
Csharp :: console.out 
Csharp :: button next for picturebox c# 
Csharp :: wpf change the content of the button wait 5 secound and then change it again 
Csharp :: Console.WriteLine($"Hello {Ana.ToUpper($)}!"); 
Csharp :: best free Modern Design frameworks C# 
Csharp :: c# blazor update state 
Csharp :: Showing a hidden WPF window 
Csharp :: c# convert linq jValue to int 
Csharp :: php check syntax error folder 
Csharp :: c# supplier equivalent 
Csharp :: Enum into table C# 
Csharp :: .net core api routing not working 
Csharp :: if statement to check if a time is between two times c# 
Csharp :: check if app have administrator rights c# 
Csharp :: log4net.dll 
Csharp :: C# Character and String Literals 
Csharp :: how to pass object as test case in nunit c# 
Csharp :: c# boolean 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =