Hello Guys,
I am trying to code this assignment below but I can't seem to get the running total
stored for each user that I have listed below(A, B, E). Can someone guide me on how
I can store the running total for each user so that I can have it stored when the
user enters "Z"? I have searched on different webpages and forums but I have yet
to find one that helps? I joined this forum to help me in my assistance to
conquer .NET(C#)so that I can be a developer in this. Can someone assist me kindly?
(I am a current I.T. professional and this sucks that I can't seem to solve it, it seems
so simple.)
Assignment question:
Three salespeople work at Sunshine Hot Tubs-Andrea, Brittany, and Eric.
Write a program that prompts the user for a salesperson’s initial (‘A’,’B’, or’E’).
While the user does not type ‘Z’, continue by prompting for the amount of
a sale the salesperson made. Calculate the salesperson’s commission as
10 percent of the sale amount, and add the commission to a running total
for that salesperson. After the user types ‘Z’ for an initial, display each
salesperson’s total commission earned.
using System;
public class TubSales
{
public static void Main()
{
string inputString;//This grabs the user's response for the salespersons initial.
char response;
Console.WriteLine("Please enter a salesperson's initial('A' for Andrea, 'B' for Brittany and 'E' for Eric and 'Z'to display each saleperson's total commmission earned)");
inputString = Console.ReadLine();
response = Convert.ToChar(inputString);
double saleAmount = new double();
double saleAmount_A = new double();
double saleAmount_B = new double();
double saleAmount_E = new double();
double commission = 0.10 * saleAmount;
while (response != 'Z')
{
if (response == 'A')
{
Console.WriteLine("Permitted user please enter the sale amount that you made.");
inputString = Console.ReadLine();
saleAmount = Convert.ToDouble(inputString);
saleAmount_A = commission;
saleAmount_A += saleAmount;
}
if (response == 'B')
{
Console.WriteLine("Permitted user please enter the sale amount that you made.");
inputString = Console.ReadLine();
saleAmount = Convert.ToDouble(inputString);
saleAmount_B = commission;
saleAmount_B += commission;
}
if (response == 'E')
{
Console.WriteLine("Permitted user please enter the sale amount that you made.");
inputString = Console.ReadLine();
saleAmount = Convert.ToDouble(inputString);
saleAmount_E = commission;
saleAmount_E += commission;
}
}
while (response == 'Z')
Console.WriteLine("The total commission for each salesperson respectively is: Andrea with {0}, Brittany with {1} and Eric with {2}.", saleAmount_A.ToString("C"), saleAmount_B.ToString("C"), saleAmount_E.ToString("C"));
}
}