Advertisement
Guest User

Untitled

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