Advertisement
illiden

StoreQueue

Jul 1st, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Store
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Random random = new Random();
  11.             Queue<int> cutomerAmounts = new Queue<int>();
  12.             int purse = 0;
  13.  
  14.             for(int i = 0; i < random.Next(20, 101); i++)
  15.             {
  16.                 cutomerAmounts.Enqueue(random.Next(50, 301));
  17.             }
  18.  
  19.             while(cutomerAmounts.Count > 0)
  20.             {
  21.                 int currentCustomerAmount = cutomerAmounts.Dequeue();
  22.                 purse += currentCustomerAmount;
  23.                 Console.Write("Идет обслуживание клиента...\n" +
  24.                               "Вам заплатили " + currentCustomerAmount + " денег\n" +
  25.                               "Текущий счет: " + purse + "\n" +
  26.                               "Нажмите любую клавишу, чтобы обслужить следующего клиента");
  27.                 Console.ReadKey();
  28.                 Console.Clear();
  29.             }
  30.  
  31.             Console.WriteLine("Это был последний клиент, вы заработали " + purse + " денег");
  32.             Console.ReadKey();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement