Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- namespace HomeWorks
- {
- class Program
- {
- static void Main(string[] args)
- {
- Queue<int> prices = new Queue<int>();
- int sum = 0;
- bool isOpen = true;
- while (isOpen)
- {
- Console.Clear();
- ServeBuyer(prices, ref isOpen);
- Console.ReadKey();
- }
- foreach(var price in prices)
- {
- sum += price;
- }
- Console.Write($"За сегодня, выручка составила: {sum}.\nДля выхода из програмы, нажмите любую клавишу...");
- Console.ReadKey();
- }
- static void ServeBuyer(Queue<int> prices, ref bool isOpen)
- {
- int buyerNumber = 0;
- while (isOpen)
- {
- Console.Clear();
- Console.Write($"ОБСЛУЖИВАНИЕ КЛИЕНТА №{++buyerNumber}\n\nвведите end, когда обслужите покупателя\n\nВведите сумму покупки: ");
- string userInput = Console.ReadLine();
- if (int.TryParse(userInput, out int price))
- {
- prices.Enqueue(price);
- }
- else if (userInput == "end")
- {
- isOpen = false;
- }
- else
- {
- Console.WriteLine("Такой команды нет!");
- Console.ReadKey();
- }
- }
- Console.Clear();
- }
- }
- }
Add Comment
Please, Sign In to add comment