Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active April 23, 2025 12:09
Show Gist options
  • Select an option

  • Save Strelok78/ef0524e5099286f673304a703910bbfb to your computer and use it in GitHub Desktop.

Select an option

Save Strelok78/ef0524e5099286f673304a703910bbfb to your computer and use it in GitHub Desktop.
Dequeue the queue in shop and calculate balance
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