Advertisement
silvana1303

cinema

Apr 30th, 2020
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int capacity = int.Parse(Console.ReadLine());
  10.             int income = 0;
  11.             string command = Console.ReadLine();
  12.  
  13.             while (command != "Movie time!")
  14.             {
  15.                 int traffic = int.Parse(command);
  16.                 capacity -= traffic;
  17.  
  18.                 if (capacity < 0)
  19.                 {
  20.                     Console.WriteLine("The cinema is full.");
  21.                     break;
  22.                 }
  23.  
  24.                 if (traffic % 3 == 0)
  25.                 {
  26.                     income += traffic * 5 - 5;
  27.                 }
  28.                 else
  29.                 {
  30.                     income += traffic * 5;
  31.                 }
  32.  
  33.                 command = Console.ReadLine();
  34.             }
  35.  
  36.             if (command == "Movie time!")
  37.             {
  38.                 Console.WriteLine($"There are {capacity} seats left in the cinema.");
  39.             }
  40.  
  41.             Console.WriteLine($"Cinema income - {income} lv.");
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement