Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C# program that includes a Employee class that can be used to calculate

ID: 3887150 • Letter: W

Question

Write a C# program that includes a 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%. 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.

Explanation / Answer

Please Refer below code:-

this first code we can test with main method go with second code where i have decare a method as per problem requirement

Code 1:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Chegg
{
public class Employee
{
public static void Main(string[] args)
{
Int32 weeklySales = 0;

while (weeklySales.Equals(0))
{
Console.WriteLine("Please Input weekly sales?");
String input = Console.ReadLine();

try
{
weeklySales = Int32.Parse(input);
}
catch
{
Console.WriteLine("Error occured in input, try again!");
}
}

Double grossPay = weeklySales * .07;
Double federalTax = grossPay * .18;
Double retirement = grossPay * .1;
Double socialSecurity = grossPay * .06;
Double totalDeductions = socSecurity + retirement + fedTax;
Double takeHomePay = grossPay - totDeductions;

Console.Write(" Your Weekly Sale amount is :" + weeklySales + "$ Gross Pay: " + grossPay + "$ Fed Tax: " + federalTax + "$ Retirement: " + retirement + "$ Social Security: " + socialSecurity + "$ Total Deductions: " + totDeductions + "$ Making your take home pay: " + takeHomePay + "$");
Console.Read();
}
}
}

Here is code 2:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Chegg
{
public class Employee
{
public double takeHome(weekelySales)
{
//Int32 weeklySales = 0;

while (weeklySales.Equals(0))
{
Console.WriteLine("Please Input weekly sales?");
String input = Console.ReadLine();

try
{
weeklySales = Int32.Parse(input);
}
catch
{
Console.WriteLine("Error occured in input, try again!");
}
}

Double grossPay = weeklySales * .07;
Double federalTax = grossPay * .18;
Double retirement = grossPay * .1;
Double socialSecurity = grossPay * .06;
Double totalDeductions = socSecurity + retirement + fedTax;
Double takeHomePay = grossPay - totDeductions;

return takeHomePay;
}
}
}

Now you can create any other class and create a object of this employee class like

Employee employee = new Employee("Aman");

Now

employee.takeHome(133350.85)<-- this is a mutator method, because it will be mutating (or changing) a value within the class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote