Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active May 17, 2023 07:20
Show Gist options
  • Save Strelok78/6d2763b072dadcefdf38e33aa6905ee2 to your computer and use it in GitHub Desktop.
Save Strelok78/6d2763b072dadcefdf38e33aa6905ee2 to your computer and use it in GitHub Desktop.
Each integer is the purchase amount. After each customer is served, money is added to the account and displayed in the console.
using System.Diagnostics;
internal class Program
{
public static void Main()
{
int companyBalance = 0;
Queue<int> queue = new Queue<int>();
queue.Enqueue(14);
queue.Enqueue(212);
queue.Enqueue(322);
queue.Enqueue(43);
queue.Enqueue(125);
queue.Enqueue(64);
queue.Enqueue(73);
queue.Enqueue(12);
queue.Enqueue(11);
queue.Enqueue(122);
while (queue.Count > 0)
{
Console.WriteLine($"Our company balance: {companyBalance}");
Console.SetCursorPosition(0, 3);
companyBalance += queue.Peek();
Console.WriteLine("Order payment: " + queue.Dequeue());
foreach (int i in queue)
{
Console.WriteLine("Next bill: " + i);
}
Console.ReadKey();
Console.Clear();
}
Console.WriteLine($"Final daily balance: {companyBalance}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment