Advertisement
Rodunskiy

Untitled

Jun 8th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. class program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         Queue<int> shoppingList = new Queue<int>();
  6.  
  7.         FillQueue(shoppingList);
  8.         ServeСlients(shoppingList);
  9.     }
  10.  
  11.     private static void ServeСlients(Queue<int> shoppingList)
  12.     {
  13.         int score = 0;
  14.  
  15.         while (shoppingList.Count > 0)
  16.         {
  17.             Console.WriteLine($"Клиент заплатил {shoppingList.Peek()} рублей.");
  18.             score += shoppingList.Dequeue();
  19.             Console.WriteLine($"Сумма в кассе: {score}");
  20.             Console.ReadLine();
  21.             Console.Clear();
  22.         }
  23.  
  24.         Console.WriteLine($"Сумма в кассе: {score}");
  25.     }
  26.  
  27.     private static void FillQueue(Queue<int> shoppingList)
  28.     {
  29.         shoppingList.Enqueue(100);
  30.         shoppingList.Enqueue(150);
  31.         shoppingList.Enqueue(200);
  32.         shoppingList.Enqueue(250);
  33.         shoppingList.Enqueue(300);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement