メソッドのオーバーロードなし。私は何を間違っていますか? 私の頭はすでに痛いです:)
//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 という名前の 2 番目のクラスです。これは、プログラムが機能しない理由がわからない場所です。
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;
}
}
}
どんな助けでも喜んでいただければ幸いです:)