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"));
    }
}

Calculating commission at the beginning like that will just calculate it once, and with the wrong amount for the sale.
Firstly, turn the whole thing into a do while loop because you have a while at both ends and that doesn't make sense.
Then make commissionA, commissionB and commissionE variables. commissionA+=(0.10*saleAmount); and saleAmountA+=saleAmount; If it helps you, run through it on paper with the values your variables take on. You're most of the way there, just read up on some stuff.

Also, I think the code snippet heading is used more for folks that have a function they want to add to the library for the site....

Remove line 52. At that point in your code, you know that response is Z(see previous while) Besides that you are creating what is called an endless while here. It will go on printing the output of your program for ever. You need this output only once.
B.T.W. be carefull when you use terms like I.T. professional...

Remove line 52. At that point in your code, you know that response is Z(see previous while) Besides that you are creating what is called an endless while here. It will go on printing the output of your program for ever. You need this output only once.
B.T.W. be carefull when you use terms like I.T. professional...

Ok thanks guys, let me try this now! Thanks a great deal for guiding me on this request.

Regards,

Ok thanks guys, let me try this now! Thanks a great deal for guiding me on this request.

Regards,

I got it solved you all! Thanks for you help! I'll post my results here for future readers with the same problem.

Thanks,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.