Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Les3
- {
- class Program
- {
- static void Main(string[] args)//Программа бронированя столиков (целиком), для заданного количества человек, с выбором столика
- {
- int[] table = { 2, 4, 2, 4, 6, 4, 6, 8, 8 };
- int[] tablePrice = { 500, 1000, 500, 1000, 2000, 1000, 2000, 3000, 3000 };
- int amount;
- string answer;
- while (true)
- {
- Console.Clear();
- for (int i = 0; i < table.Length; i++)
- {
- Console.WriteLine((i + 1) + " стол - на " + table[i]+ " мест(а)");
- }
- Console.WriteLine("Введите 0 чтобы выйти.");
- Console.Write("На сколько человек вы хотите забронировать стол? ");
- amount = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Вы можете забронировать: ");
- for (int i = 0; i < table.Length; i++)
- {
- if (amount<=table[i]&&(amount+2)>=table[i])//делаю проверку, чтобы за слишком большим столом не сидело мало людей
- {
- Console.WriteLine("стол под номером " +(i+1)+" на " + table[i]+ " мест");
- }
- }
- Console.Write("Введите номер выбранного вами стола: ");
- int userInputTable = Convert.ToInt32(Console.ReadLine()) - 1;
- if (userInputTable < 1)
- break;
- if (userInputTable > table.Length - 1)
- {
- Console.Write("Такого стола нет.");
- Console.ReadKey();
- continue;
- }
- Console.WriteLine("Стоимость брони стола: " + tablePrice[userInputTable] + " рублей\n Вы согласны его забронировать?");
- answer = Console.ReadLine();
- if(answer == "да"|| answer == "Да")
- {
- Console.WriteLine("Поздравляю, стол №" + userInputTable + " забронирован ");
- table[userInputTable] = 0;
- }
- else
- {
- Console.WriteLine("Вы можете выбрать другой стол");
- Console.ReadKey();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement