方法没有重载。我究竟做错了什么?我的头已经疼了:)
//this is the first class named Employee
namespace lala
{
public class Employee
{
public static double GrossPay(double WeeklySales) //grosspay
{
return WeeklySales * .07;
}
public static double FedTaxPaid(double GrossPay)
{
return GrossPay * .18;
}
public static double RetirementPaid(double GrossPay)
{
return GrossPay * .1;
}
public static double SocSecPaid(double GrossPay)
{
return GrossPay * .06;
}
public static double TotalDeductions(double SocSecPaid, double RetirementPaid, double FedTaxPaid)
{
return SocSecPaid + RetirementPaid + FedTaxPaid;
}
public static double TakeHomePay(double GrossPay, double TotalDeductions)
{
return GrossPay - TotalDeductions;
}
}
}
这是名为 EmployeeApp 的第二个类,这是我不知道为什么我的程序不起作用的地方
namespace lala
{
public class EmployeeApp
{
public static string name;
public static double WeeklySales;
public static void Main()
{
Employee yuki = new Employee();
GetInfo();
Console.WriteLine();
Console.WriteLine("Name: {0}", name);
Console.WriteLine();
Console.WriteLine("Gross Pay : {0}", yuki.GrossPay());
Console.WriteLine("Federal Tax Paid : {0}", yuki.FedTaxPaid());
Console.WriteLine("Social Security Paid : {0}", yuki.SocSecPaid());
Console.WriteLine("Retirement Paid : {0}", yuki.RetirementPaid());
Console.WriteLine("Total Deductions : {0}", yuki.TotalDeductions());
Console.WriteLine();
Console.WriteLine("Take-Home Pay : {0}", yuki.TakeHomePay());
Console.ReadKey();
}
public static string GetInfo()
{
Console.Write("Enter Employee Name : ");
name = Console.ReadLine();
Console.Write("Enter your Weekly Sales : ");
WeeklySales = Convert.ToDouble(Console.ReadLine());
return name;
}
}
}
任何帮助将不胜感激:)