Last active
April 23, 2025 12:09
-
-
Save Strelok78/ef0524e5099286f673304a703910bbfb to your computer and use it in GitHub Desktop.
Dequeue the queue in shop and calculate balance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Diagnostics; | |
| namespace iJuniorPractice; | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Queue<int> paymentsInQueue = new Queue<int>(new []{100, 25, 10, 50, 75}); | |
| int shopAccount = 0; | |
| int payment; | |
| while (paymentsInQueue.Count > 0) | |
| { | |
| Console.WriteLine($"Shop balance = {shopAccount}"); | |
| payment = paymentsInQueue.Dequeue(); | |
| shopAccount += payment; | |
| Console.WriteLine($"Client payeed {payment}"); | |
| Console.WriteLine("Eneter any key to continue..."); | |
| Console.ReadKey(); | |
| Console.Clear(); | |
| } | |
| Console.WriteLine($"No more clients, shop balance = {shopAccount}"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment