Write a program that includes an Employee class in C# that can be used to calcul
ID: 3676145 • Letter: W
Question
Write a program that includes an Employee class in C# 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.
Explanation / Answer
Console.WriteLine("What are your weekly sales?"); try { Int32 weeklySales = Int32.Parse(Console.ReadLine()); Double grossPay = weeklySales * .07; Double fedTax = grossPay * .18; Double retirement = grossPay * .1; Double socSecurity = grossPay * .06; Double totDeductions = socSecurity + retirement + fedTax; Double takeHomePay = grossPay - totDeductions; Console.Write(" Your Weekly Sale amount is :" + weeklySales + "$ Gross Pay: " + grossPay + "$ Fed Tax: " + fedTax + "$ Retirement: " + retirement + "$ Social Security: " + socSecurity + "$ Total Deductions: " + totDeductions + "$ Making your take home pay: " + takeHomePay + "$"); Console.Read(); } catch { Console.WriteLine("There is an error in input. Program will be terminated."); }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.