Advertisement
Valantina

Cinema

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