Question

Payroll Application Problem Description: An org needs a payroll application which has the capability to calculate...

Payroll Application

Problem Description:

An org needs a payroll application which has the capability to calculate and print the monthly pay of an employee. The application starts by printing a short description of what it does. Then, it asks for the employee name. Next, the application prompts for employee type (“H” for hourly and “S” for salaried.) If the user enters S, the gross pay is set to $4000. However, if the user enters H for an hourly employee, the application asks for the number of hours worked and the hourly rate and these are used to calculate the gross pay.

The deductions from the paycheck before tax cuts are contributions to health insurance ($300) and retirement plan (6%). The federal income tax (15%) and state income tax (5%) are deducted after the contributions to health and retirement are deducted from the gross pay. A sample payslip for each kind of employee is shown in the screenshots below. Make sure your application’s output is similar or better than the screenshots given below.

Technical Specifications

  • You should explain your code by providing adequate commenting.
  • You will need two class files for this application. One will be called Payroll and the other PayrollTest.
  • The program must ask for the name, and the employee type. The name and employee type should be stored as instance variables with appropriate properties. You will also need another instance variable to store the Gross Pay of the employee. The value for this variable will depend on the type of employee. If the employee is an hourly employee it should ask for the number of hours worked, and the hourly rate for the employee to calculate the gross pay.
  • The program must then process the information and output it as shown in the samples above. All processing of the Net Pay will be done by a method in the Payroll class.
  • All output must be printed by a method in the Payroll class. The output must print:
    • Payslip Header
    • The Gross Pay amount (rounded to two decimal places)
    • The contributions to health and retirement plans and the federal and state tax amounts.
    • And finally, the net pay amount (rounded to two decimal places)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

Here a new Console Application in C# is created using Visual Studio 2017 with name "PayrollApplication".This application conatins class "Payroll.cs" and one test class for testing payroll class that is "PayrollTest.cs".Below is the details about these classes.

Payroll.cs :

//namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace PayrollApplication
{
//class Payroll
class Payroll
{
//property name
public string Name { get; set; }
//Employee Type
public string EmployeeType { get; set; }
//Gross Pay
public double GrossPay { get; set; }

//method to calculate details
public void calculateNetPay(double grossPay)
{
//health contribution
double helathInsuranceContribution = 300;
//retirement contribution
double retirementContribution=(grossPay * 6) / 100;
//Amount for tax deductions
double amountForTaxDeduction = grossPay - 300 - retirementContribution;
//Federal Income Tax
double federalIncomeTax = amountForTaxDeduction * 15 / 100;
//State Income Tax
double stateIncomeTax = amountForTaxDeduction * 5 / 100;
Console.WriteLine("***************************************");
//printing payslip details
Console.WriteLine($"PAY SLIP FOR : {Name} , MONTH : {DateTime.Now.Month}, {DateTime.Now.Year}");
Console.WriteLine("***************************************");
//display employee type
Console.WriteLine($"Employee Type :{EmployeeType}");
Console.WriteLine($"Monthly Gross Pay : {grossPay.ToString("0.00")} ");
Console.WriteLine("-------------------------------------------");
//display monthly contrbutions
Console.WriteLine("MONTHLY CONTRIBUTIONS");
Console.WriteLine($"Helath : {helathInsuranceContribution} Retirement : {retirementContribution} ");
Console.WriteLine("-------------------------------------------");
//display taxes
Console.WriteLine("TAX DEDUCTIONS");
Console.WriteLine($"Amount on which Tax Deducted : {amountForTaxDeduction} ");
Console.WriteLine($"Federal Income Tax : {federalIncomeTax}, State Income Tax : {stateIncomeTax}");
Console.WriteLine($"============================================ ");
//display net pay
Console.WriteLine($"NET PAY : {(amountForTaxDeduction- federalIncomeTax- stateIncomeTax).ToString("0.00")} ");

}
}
}

**********************************

PayrollTest.cs :

//namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace PayrollApplication
{
//class PayrollTest
class PayrollTest
{
//Main Method
static void Main(string[] args)
{
//creating Payroll Object
Payroll payroll = new Payroll();
//asking user to enter employee name
Console.WriteLine("Enter Employee Name : ");
//Reading Employee Name
payroll.Name = Console.ReadLine();
//askin employee type
Console.WriteLine("Enter Employee Type (“H” for hourly and “S” for salaried.) : ");
//reading employee Type
payroll.EmployeeType = Console.ReadLine();
//checking employee type
if(payroll.EmployeeType=="S")
{
//if salaried employee
payroll.GrossPay = 4000;
//calling method to calculate taxes and contributions and print pay slip
payroll.calculateNetPay(payroll.GrossPay);
}
else if (payroll.EmployeeType == "H")
{
//if Hourly employee
//asking user number of hours worked
Console.WriteLine("Enter Number of Hours Worked : ");
//reading hours
double hours = double.Parse(Console.ReadLine());
//asking user hourly rate
Console.WriteLine("Enter Hourly Rate : ");
//reading hourly rate
double hourlyRate = double.Parse(Console.ReadLine());
//calculating gross pay
payroll.GrossPay = hours*hourlyRate;
//calling method to calculate taxes and contributions and print pay slip
payroll.calculateNetPay(payroll.GrossPay);
}
//to hold the screen
Console.ReadKey();

}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :Screen asking Employee Name

Screen 2 :Screen asking Employee Type

Screen 3 :Screen showing payslip for Salaried Employee

Screen 4 :Screen showing payslip for Hourly Employee

Add a comment
Know the answer?
Add Answer to:
Payroll Application Problem Description: An org needs a payroll application which has the capability to calculate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Java application with a class name of Payroll, for the “Travel Agency”, that willCalculate...

    Write a Java application with a class name of Payroll, for the “Travel Agency”, that willCalculate the weekly paycheck for both Salaried and Hourly employees. Salaried employees will be paid 1/52 of their annual pay minus 18% withheld for federal and state taxes, as well as 4% for retirement pension. Salaried employees do not collect overtime pay. There are two types of Hourly employees; permanent employees and temporary weekly employees. •Permanent weekly employees will be paid their hourly rate minus...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • Calculate Payroll computer programmer, and an administrator. The following payroll information is available for each K....

    Calculate Payroll computer programmer, and an administrator. The following payroll information is available for each K. Mello Company has three employees-a consultant, employee Administrator Consultant Computer Programmer $3,110 per week Regular earnings rate $36 per hour $44 per hour Overtime earnings rate 1.5 times hourly rate Not applicable 2 times hourly rate Federal income tax withheld $930 $244 $510 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay period,...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll...

    java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: • An empty string is given for the employee’s name. • An invalid value is given for the employee’s ID number. If you implemented this field as a string, then an empty string would be invalid. If you implemented this field as a numeric variable, then a negative number or...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $36 per hour $3,010 per week Not applicable $48 per hour 1.5 times hourly rate Overtime earnings rate 2 times hourly rate Federal income tax withheld $930 $246 $505 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $3,010 per week $36 per hour $50 per hour Overtime earnings rate Not applicable 2 times hourly rate 1.5 times hourly rate Federal income tax withheld $910 $258 $515 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,710 per week $50 per hour $30 per hour 2 times hourly rate Not applicable 1.5 times hourly rate Overtime earnings rate Federal income tax withheld $925 $239 $500 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,010 per week $30 per hour $42 per hour Overtime earnings rate Not applicable 2 times hourly rate 1.5 times hourly rate Federal income tax withheld $910 $251 $495 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT