Validation 更正代码。还需要对用户输入进行验证检查

Validation 更正代码。还需要对用户输入进行验证检查,validation,input,Validation,Input,问题说明: 编写一个C#程序,只使用一个包含Main()方法的类和该类中的许多其他方法来计算委托销售员工的实际工资。 员工在一周内收到总销售额的7%作为佣金。这是工资总额。 从收到的工资总额中扣除以下款项,具体依据如下: •联邦税率为16%。 •退休供款为13%。 •8%的社会保障税。 作为解决方案的一部分: •编写一种向用户显示适当说明的方法。 •只编写一个方法,调用或调用两次,分别获取员工姓名和本周的总销售额。 •编写六种单独的方法来计算以下各项: o总薪酬 o联邦减税 o退休供款扣除 o社

问题说明: 编写一个C#程序,只使用一个包含Main()方法的类和该类中的许多其他方法来计算委托销售员工的实际工资。 员工在一周内收到总销售额的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();
        }
    }
}

我投票以离题结束这个问题,因为这似乎是一个家庭作业。我投票以离题结束这个问题,因为这似乎是一个家庭作业。