我不知道如何将总计、销售和通信传递给 Main()。
有人知道如何将这些变量放入 Main 并在其中显示(输出)它们的名称吗?
现在我可以在 calcComm 中输出变量...
提前致谢
菲利普
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication38
{
class Program
{
public static void getsales()
{
string inputsales;
double total = 0;
double sale = 0;
for (int salecount = 1; salecount <= 3; ++salecount)
{
Console.WriteLine("Enter sale: ");
inputsales = Console.ReadLine();
sale = Convert.ToDouble(inputsales);
total = total + sale;
}
calcComm(total);
}
public static void calcComm(double total)
{
double comm = 0;
comm = total * 0.2;
Console.WriteLine(comm);
}
public static void Main ()
{
Console.WriteLine(" Sunshine Hot Tubs \n Sales Commissions Report\n");
char Letter;
const string name1 = "Andreas";
const string name2 = "Brittany";
const string name3 = "Eric";
string inputLetter;
string name;
Console.WriteLine("Please enter intial or type 'z' to quit");
inputLetter = Console.ReadLine();
Letter = Convert.ToChar(inputLetter);
while (Letter != 'z')
{
if (Letter == 'a')
{
name = name1;
getsales();
}
else if (Letter == 'b')
{
name = name2;
getsales();
}
else if (Letter == 'e')
{
name = name3;
getsales();
}
else
{
Console.WriteLine("Invalid entry try again");
}
Console.WriteLine("Please enter intial or type z to quit");
inputLetter = Console.ReadLine();
Letter = Convert.ToChar(inputLetter);
}
}
}
}