Advertisement
NelIfandieva

Ex06_Pr06_CinemaTickets

Jun 12th, 2022
927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P06_CinemaTickets
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int totalTicketsForDay = 0;
  10.  
  11.             int studentTickets = 0;
  12.             int standardTickets = 0;
  13.             int kidTickets = 0;
  14.  
  15.             string input = "";
  16.  
  17.             while (input != "Finish")
  18.             {
  19.                 input = Console.ReadLine(); // "Kit"
  20.  
  21.                 if(input == "Finish")
  22.                 {
  23.                     break;
  24.                 }
  25.  
  26.                 string filmTitle = input;
  27.  
  28.                 int seatsAvailable = int.Parse(Console.ReadLine());
  29.  
  30.                 int currentAvailSeats = seatsAvailable;
  31.  
  32.                 int tickSoldForFilm = 0;
  33.  
  34.                 string ticketType = "";
  35.  
  36.                 while (ticketType != "End" && currentAvailSeats > 0)
  37.                 {
  38.                     ticketType = Console.ReadLine();
  39.  
  40.                     if(ticketType == "End")
  41.                     {
  42.                         break;
  43.                     }
  44.  
  45.                     tickSoldForFilm++;
  46.                     totalTicketsForDay++;
  47.                     currentAvailSeats--;
  48.  
  49.                     switch(ticketType)
  50.                     {
  51.                         case "standard":
  52.                             standardTickets++;
  53.                             break;
  54.                         case "student":
  55.                             studentTickets++;
  56.                             break;
  57.                         case "kid":
  58.                             kidTickets++;
  59.                             break;
  60.                     }
  61.                 }
  62.  
  63.                 double percentageFull = tickSoldForFilm / (seatsAvailable * 1.0) * 100;
  64.                 Console.WriteLine($"{filmTitle} - {percentageFull:f2}% full.");
  65.             }
  66.  
  67.             Console.WriteLine($"Total tickets: {totalTicketsForDay}");
  68.  
  69.             double percStudents = studentTickets / (totalTicketsForDay * 1.0) * 100;
  70.             Console.WriteLine($"{percStudents:f2}% student tickets.");
  71.  
  72.             double percStandard = standardTickets / (totalTicketsForDay * 1.0) * 100;
  73.             Console.WriteLine($"{percStandard:f2}% standard tickets.");
  74.  
  75.             double percKids = kidTickets / (totalTicketsForDay * 1.0) * 100;
  76.             Console.WriteLine($"{percKids:f2}% kids tickets.");
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement