问题规范: 只使用一个包含Main()方法的类和该类中的许多其他方法来编写C#程序,以计算委托销售员工的实得工资。 员工每周收到总销售额的7%作为佣金。这是总薪酬。 以下扣除额是根据以下方式收到的总薪酬: •联邦税率为16%。 •退休金为13%。 •社会保障税为8%。 作为解决方案的一部分: •编写一种方法以向用户显示适当的指令。 •只编写一个要调用或调用两次的方法,以分别获取员工姓名和一周的总销售额。 •编写六种不同的方法来计算以下内容: o总薪酬 o联邦税收减免 o退休金扣除额 o社会保障扣除 o本周扣除总额 o本周带薪回家 •编写一种方法以使用适当的消息显示结果,包括 o员工姓名, o总销售额 o总薪酬 o扣除联邦税, o扣除社会保障税, o退休金, o扣除总额 o总回家支付
注意: 调用每个方法时,只将参数作为变量传递。
节目输入 允许用户输入员工的姓名以及该员工一周的总销售额。您的计划只需要处理一名员工。 注意: 如果输入不符合所需语法,程序必须生成相应的错误消息。 节目输出: 您的最终输出应显示所有计算值,所有已定义的常量和员工的姓名。 注意: 1.输出必须以可读格式显示。 2.使用适当的输入
测试您的代码using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace totalSalaryCalculator
{
class totalsalarycalculator
{
static void Main(string[] args)
{
string employeeName;
double saleForWeek;
double grossPay;
double fedTaxDeduction;
double socialSecDeduction;
double totalDeductions;
double takeHomePay;
double retirementContri;
DisplayInstructions();
employeeName = GetInformation();
saleForWeek = GetInformation();
grossPay = GetGrossPay(saleForWeek);
retirementContri = GetRetContri(grossPay);
socialSecDeduction = GetSSdeduction(grossPay);
fedTaxDeduction = GetFedTax(grossPay);
totalDeductions = GetDeduction(fedTaxDeduction, retirementContri, socialSecDeduction);
takeHomePay = GetNetPay(grossPay, totalDeductions);
DisplayResults(employeeName, saleForWeek, grossPay, fedTaxDeduction, socialSecDeduction, retirementContri, takeHomePay);
}
public static void DisplayInstructions()
{
Console.WriteLine("This Program Calculates the Net Salary" + " of the employee for a week\n");
Console.WriteLine("How much of the sale's target you were able to achieve for one week\n");
Console.WriteLine("you will be asked to enter the total sales for a week\n");
Console.WriteLine("The gross pay will be calculated accordingly\n");
Console.WriteLine("Gross pay is seven pecent" + " of the Total sales for a week\n");
Console.WriteLine();
Console.WriteLine("The Retirement Contribution will also be deducted from the Gross pay\n");
Console.WriteLine("The taxes deducted will be Federal Tax,Social Security Tax\n");
Console.WriteLine("The Federal tax will be 16 percent of the gross pay\n");
Console.WriteLine("The Social Security Tax will be 8 percent of the Gross pay\n");
Console.WriteLine("The Retirement Contribution Will be 13 percent of the Gross pay\n");
Console.WriteLine();
Console.WriteLine("\nYou will be asked to enter your name");
Console.WriteLine("\nAnd You will be asked to enter the total sale you were able to achieve for a week");
Console.WriteLine();
Console.WriteLine("Press any key when you are ready to begin");
Console.ReadKey();
Console.Clear();
}
public static double GetInformation(string name,string sale)
{
string inputvalue;
string inputvalue2;
double totalSales;
double nameOfPerson;
Console.Write("Enter the name of Employee: ");
inputvalue= Console.ReadLine();
nameOfPerson = double.Parse(inputvalue);
Console.Write("Enter the Total Sales for the Week: ");
inputvalue2 = Console.ReadLine();
totalSales = double.Parse(inputvalue2);
return ( nameOfPerson + totalSales);
}
public static double GetGrossPay(double saleForWeek)
{
double grosspay;
grosspay = 7 / 100 * saleForWeek;
return grosspay;
}
public static double GetFedTax(double grossPay)
{
double fedtax;
fedtax = 16 / 100 * grossPay;
return fedtax;
}
public static double GetRetContri(double grossPay)
{
double retcontri;
retcontri = 13 / 100 * grossPay;
return retcontri;
}
public static double GetSSdeduction(double grossPay)
{
double ssdeduction;
ssdeduction = 8 / 100 * grossPay;
return ssdeduction;
}
public static double GetDeduction(double fedTaxDeduction, double retirementContri, double socialSecDeduction)
{
double totdeductions;
totdeductions = fedTaxDeduction + retirementContri + socialSecDeduction;
return totdeductions;
}
public static double GetNetPay(double grossPay, double totalDeductions)
{
double netpay;
netpay = grossPay - totalDeductions;
return netpay;
}
public static void DisplayResults(string employeeName, double saleForWeek, double grossPay, double fedTaxDeduction, double retirementContri, double socialSecDeduction,
double takeHomePay)
{
Console.WriteLine("Employee Name: " + employeeName);
Console.WriteLine("Total Sales entered by the Employee: "+ saleForWeek);
Console.WriteLine("Gross Pay for a week: " + grossPay);
Console.WriteLine("Federal Tax Deduction for a week: " + fedTaxDeduction);
Console.WriteLine("Social security Deduction for a week: " + socialSecDeduction);
Console.WriteLine("Retirement Contribution for a week: " + retirementContri);
Console.WriteLine("Total Deductions for a week: " + GetDeduction(fedTaxDeduction, retirementContri, socialSecDeduction));
Console.WriteLine("Take Home Pay for a week: " + takeHomePay);
Console.ReadKey();
}
}
}