小さなコンソールアプリはほとんど機能しましたが、唯一の問題は、変数totalComm
の値が 0 のままであることです。
私はすべてを試しましたが、おそらく問題を解決する小さな修正を見落としていました。
前もって感謝します
フィリップ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CommissionCalculator
{
class Program
{
public static void Main()
{
double total;
double comm = 0;
double totalComm = 0;
string name = "";
string inputLetter = "";
int whilecount = 0;
while (inputLetter != "z")
{
if (whilecount == 0)
{
Title();
whilecount = whilecount + 1;
}
getNameSales(out inputLetter, out name, out total, comm, totalComm);
calcComm(total, out comm);
outputVar(name, total, comm);
totalCommCalc(comm, totalComm);
}
}
public static void Title()
{
Console.WriteLine("\n Sunshine Hot Tubs \n Sales Commissions Report\n");
}
public static void getNameSales(out string inputLetter, out string name, out double total, double comm, double totalComm)
{
name = "";
inputLetter = "";
total = 0;
Console.WriteLine("\nEnter salespersons initial a,b or e or enter z to quit");
inputLetter = Console.ReadLine();
if (inputLetter == "a")
{
name = "Andrea";
string inValue;
double sale = 0;
total = 0;
for (int count = 1; count <= 3; ++count)
{
Console.WriteLine("Please enter sale: ");
inValue = Console.ReadLine();
sale = Convert.ToDouble(inValue);
total = total + sale;
}
}
else if (inputLetter == "b")
{
name = "Brittany";
string inValue;
double sale = 0;
total = 0;
for (int count = 1; count <= 3; ++count)
{
Console.WriteLine("Please enter sale: ");
inValue = Console.ReadLine();
sale = Convert.ToDouble(inValue);
total = total + sale;
}
}
else if (inputLetter == "e")
{
name = "Eric";
string inValue;
double sale = 0;
total = 0;
for (int count = 1; count <= 3; ++count)
{
Console.WriteLine("Please enter sale: ");
inValue = Console.ReadLine();
sale = Convert.ToDouble(inValue);
total = total + sale;
}
}
else if (inputLetter == "z")
{
totalCommCalc(comm, totalComm);
Console.WriteLine("Total commssion paid: {0:C}", totalComm);
Console.ReadKey();
}
}
public static void calcComm(double total, out double comm)
{
comm = total * 0.2;
}
public static double totalCommCalc(double comm, double totalComm)
{
totalComm = totalComm + comm;
return totalComm;
}
public static void outputVar(string name, double total, double comm)
{
Console.WriteLine("\n Name\t Total sales\t Commission \n{0} \t {1} \t {2}", name, total, comm);
}
}
}