This is a homework assignment so I understand that answers cannot be given.
I have been having trouble trying to figure out how to create a running total in my do while loop so that after displaying each customer's total, it can display the grand total. I have started a new variable called RunningTotal but I have not been able to incorporate it properly. Every time I try to add it in, it just skips to the GrandTotal instead of adding another customer or just takes one customer's input. I hope this makes sense. Any help is appreciated! Thank you!
So is RunningGameTotal the grand total of all of the games from all of the customers? Ie. The sum of all of the GrandTotals?
I'm a little confused on your second problem... Does the loop work when you enter 'y' for a new player? Or is it exiting out of the loop and ending the program?
Yes, RunningGameTotal is the grand total of all the games from the customers.
The loop still works when I enter 'y' for a new player. The only problem I am having is when I am done adding customers and choose 'x', it only displays the last customer that was put in.
And... for lines 100-102, that was to exit if there are no more customers. I made a typo and it should have been an 'x' rather than 'n'.
OK. Lines 100-102 will not cause it to exit. That is what the while condition will do. Effectively it will loop until you enter anything other than 'y', so 'x' isn't a requirement.
As for the RunningGameTotal, can't you just do something like RunningGameTotal += GrandTotal; after you've computed the GrandTotal on line 78? You will also need to initialize RunningGameTotal to 0 on line 20 or you could end up getting junk.
The reason it is showing the last customer information after you exit the loop is that you are printing the last values that were just read or computed. If you want totals for shoe rentals, facility charges, taxes, etc... You will need to do something extra like have a counter for the number of shoe rentals, or the number of customers paying a facility charges... Then print those values at the end.
Your if/else statements on lines 32-62 can also be simplified. You have 2 cases for Choice1, so something more like this might be easier to read and manage:
1 2 3 4 5
if(Choice1 == 'd') {
//4 if/else statements for Choice2 go here for weekday rates
} elseif(Choice1 == 'e') {
//4 if/else statements for Choice2 go here for weekend rates
}