Advertisement
TwinFrame

QueueShop

Dec 10th, 2020 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4.  
  5. namespace Clight_33_QueueShop
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. float cash = 1.75f;
  12. float cost;
  13. Random random = new Random();
  14.  
  15. Queue<string> clients = new Queue<string>();
  16. clients.Enqueue("Роман");
  17. clients.Enqueue("Алексей");
  18. clients.Enqueue("Мария");
  19. clients.Enqueue("Вадим");
  20. clients.Enqueue("Анна");
  21. clients.Enqueue("Виталий");
  22. clients.Enqueue("Марина");
  23. clients.Enqueue("Сергей");
  24. clients.Enqueue("Владимир");
  25. clients.Enqueue("Евгения");
  26.  
  27. while (clients.Count > 0)
  28. {
  29. cost = Convert.ToSingle(random.Next(90, 15001))/3;
  30. Console.Clear();
  31. Console.Write("Добро пожаловать за кассу нашего магазина.");
  32. Console.Write(" Касса: ");
  33. PrintRubFormat(cash);
  34. Console.Write($"Текущий клиент: {clients.Peek()}. Сумма покупки: ");
  35. PrintRubFormat(cost);
  36. Console.WriteLine("Следующие в очереди:");
  37. clients.Dequeue();
  38.  
  39. foreach (string client in clients)
  40. {
  41. Console.WriteLine(client);
  42. }
  43.  
  44. Console.WriteLine("\nНажмите любую клавишу, чтобы обслужить.\n\n");
  45. Console.ReadKey();
  46. cash += cost;
  47. }
  48. Console.Clear();
  49. Console.WriteLine($"Рабочий день закончен.\n");
  50. Console.Write($"Касса: ");
  51. PrintRubFormat(cash);
  52. }
  53. static void PrintRubFormat(float price)
  54. {
  55. Console.Write("{0:#.##}", price);
  56. Console.WriteLine(" руб.\n");
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement