Write a program that includes an Employee class that can be used to calculate and print the take-home pay for a commissioned sales employee. All employees receive 7% of the total sales. Federal tax rate is 18%. Retirement contribution is 10%. Social Security tax rate is 6%. Write instance methods to calculate the commission income, federal and social security tax withholding amounts and the amount withheld for retirement. Use appropriate constants, design an object-oriented solution, and write constructors. Include at least one mutator and one accessor method; provide properties for the other instance variables. Create a second class to test your design. Allow the user to enter values for the name of the employee and the sales amount for the week in the second class.

Respuesta :

Answer:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

employeeNamespace EmployeeProgram

{

public class employee

{

private int employeeNumber;

private string employeeName;

private string employeeHireDate;

private int employeeMonthlySalary;

private string employeeDescription;

private string employeeDepartment;

public employee(int employeeNumber, string employeeName, string dateOfHire, int employeeMonthlySalary, string employeeDescription, string employeeDepartment)

{

this.employeeNumber = 79;

this.employeeName = "David";

this.employeeHireDate = "09/03/20";

this.employeeMonthlySalary = 34834;

this.employeeDescription = "Manager";

this.employeeDepartment = "Engineering";

}

public int EmployeeNumber

{

get

{

return employeeNumber;

}

set

{

employeeNumber = value;

}

}

public string employeeName

{

get

{

return employeeName;

}

set

{

employeeName = value;

}

}

public string employeeHireDate

{

get

{

return employeeHireDate;

}

set

{

employeeHireDate = value;

}

}

public int employeeMonthlySalary

{

get

{

return employeeMonthlySalary;

}

set

{

employeeMonthlySalary = value;

}

}

public string employeeDepartment

{

get

{

return employeeDepartment;

}

set

{

employeeDepartment = value;

}

}

public string employeeDescription

{

get

{

return employeeDescription;

}

set

{

employeeDescription = value;

}

}

public override string ToString()

{

return "Employee ID: " + employeeNumber +

"Employee employeeName: " + employeeName +

"Employee Hire Date: " + employeeHireDate +

"Employee Monthly Salary: " + employeeMonthlySalary +

"Employee employeeDescription: " + employeeDescription +

"Employee employeeDepartment: " + employeeDepartment;

}

public void Print()

{

Console.WriteLine(this.ToString());

}

}

Int32 weeklySales = 0;

while (weeklySales.Equals(0))

{

Console.WriteLine("What are your weekly sales?");

String input = Console.ReadLine();

try

{

weeklySales = Int32.Parse(input);

}

catch

{

Console.WriteLine("There is an error in your input, try again!");

}

}

Double grossPay = weeklySales * .07;

Double federalTax = grossPay * .18;

Double retirement = grossPay * .1;

Double socialSecurity = grossPay * .06;

Double totDeductions = socialSecurity + retirement + federalTax;

Double homePay = grossPay - totDeductions;

Console.Write("\nYour Weekly Sale amount is :" + weeklySales + "$\nGross Pay: " + grossPay + "$\nFed Tax: " + federalTax + "$\nRetirement: " + retirement + "$\nSocial Security: " + socialSecurity + "$\nTotal Deductions: " + totDeductions + "$\nMaking your take home pay: " + homePay + "$");

Explanation:

  • Declare the variables to store information about employees.
  • Initialize the getter and setter methods for the Employee class.
  • Calculate the rates by multiplying them with a suitable percentage as given in the question.
  • Finally display all the results to the console.