Advertisement
Guest User

3.1

a guest
May 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Les3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)//Программа бронированя столиков (целиком), для заданного количества человек, с выбором столика
  12.         {
  13.             int[] table = { 2, 4, 2, 4, 6, 4, 6, 8, 8 };
  14.             int[] tablePrice = { 500, 1000, 500, 1000, 2000, 1000, 2000, 3000, 3000 };
  15.             int amount;
  16.             string answer;
  17.  
  18.             while (true)
  19.             {
  20.                 Console.Clear();
  21.  
  22.                 for (int i = 0; i < table.Length; i++)
  23.                 {
  24.                     Console.WriteLine((i + 1) + " стол - на " + table[i]+ " мест(а)");
  25.                 }
  26.                 Console.WriteLine("Введите 0 чтобы выйти.");
  27.                 Console.Write("На сколько человек вы хотите забронировать стол? ");
  28.                 amount = Convert.ToInt32(Console.ReadLine());
  29.                 Console.WriteLine("Вы можете забронировать: ");
  30.                 for (int i = 0; i < table.Length; i++)
  31.                 {
  32.                     if (amount<=table[i]&&(amount+2)>=table[i])//делаю проверку, чтобы за слишком большим столом не сидело мало людей
  33.                     {
  34.                         Console.WriteLine("стол под номером " +(i+1)+" на " + table[i]+ " мест");
  35.                     }
  36.                 }
  37.                 Console.Write("Введите номер выбранного вами стола: ");
  38.                 int userInputTable = Convert.ToInt32(Console.ReadLine()) - 1;
  39.                 if (userInputTable < 1)
  40.                     break;
  41.                 if (userInputTable > table.Length - 1)
  42.                 {
  43.                     Console.Write("Такого стола нет.");
  44.                     Console.ReadKey();
  45.                     continue;
  46.                 }
  47.                 Console.WriteLine("Стоимость брони стола: " + tablePrice[userInputTable] + " рублей\n Вы согласны его забронировать?");
  48.                 answer = Console.ReadLine();
  49.                 if(answer == "да"|| answer == "Да")
  50.                 {
  51.                     Console.WriteLine("Поздравляю, стол №" + userInputTable + " забронирован ");
  52.                     table[userInputTable] = 0;
  53.                 }
  54.                 else
  55.                 {
  56.                     Console.WriteLine("Вы можете выбрать другой стол");
  57.                     Console.ReadKey();
  58.                 }
  59.  
  60.             }
  61.  
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement