Advertisement
madeofglass

Untitled

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