Advertisement
Valantina

CinemaTickets2

Jun 14th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CinemaTickets
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string filmName = Console.ReadLine();
  10.             int totalCountTickets = 0;
  11.             int totalStudentTickets = 0;
  12.             int totalStandardTickets = 0;
  13.             int totalKidTickets = 0;
  14.  
  15.             while (filmName != "Finish")
  16.             {
  17.                 int availabeSeats = int.Parse(Console.ReadLine());
  18.                 int countTicketsPerMovie = 0;
  19.  
  20.                 string command = Console.ReadLine();
  21.                 int standardTickets = 0;
  22.                 int kidTickets = 0;
  23.                 int studentTickets = 0;
  24.  
  25.                 while (command != "End")
  26.                 {
  27.                     totalCountTickets++;
  28.                     if (command == "standard")
  29.                     {
  30.                         standardTickets++;
  31.                         totalStandardTickets++;
  32.                     }
  33.                     else if (command == "kid")
  34.                     {
  35.                         kidTickets++;
  36.                         totalKidTickets++;
  37.                     }
  38.                     else if (command == "student")
  39.                     {
  40.                         studentTickets++;
  41.                         totalStudentTickets++;
  42.                     }
  43.                     countTicketsPerMovie++;
  44.                     if (countTicketsPerMovie == availabeSeats)
  45.                     {
  46.                         break;
  47.                     }
  48.  
  49.                     command = Console.ReadLine();
  50.                 }
  51.                 double percentFull = (standardTickets + kidTickets + studentTickets)*1.0 / availabeSeats * 100;
  52.                 Console.WriteLine($"{filmName} - {percentFull:F2}% full.");
  53.  
  54.                 filmName = Console.ReadLine();
  55.             }
  56.  
  57.             double percentStudentTickets = totalStudentTickets * 1.0 / totalCountTickets * 100;
  58.             double percentStandartTickets = totalStandardTickets * 1.0 / totalCountTickets * 100;
  59.             double percentKidsTickets = totalKidTickets * 1.0 / totalCountTickets * 100;
  60.  
  61.             Console.WriteLine($"Total tickets: {totalCountTickets}");
  62.             Console.WriteLine($"{percentStudentTickets:F2}% student tickets.");
  63.             Console.WriteLine($"{percentStandartTickets:F2}% standard tickets.");
  64.             Console.WriteLine($"{percentKidsTickets:F2}% kids tickets.");
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement