Advertisement
Daniel_007

09. Cinema Tickets

Oct 22nd, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Cinema Tickets
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string movie = "";
  10.             string tickets = "";
  11.  
  12.             int counterStandard = 0;
  13.             int counterKid = 0;
  14.             int counterStudent = 0;
  15.  
  16.             int counterStandardALL = 0;
  17.             int counterKidALL = 0;
  18.             int counterStudentALL = 0;
  19.  
  20.             double howMany = 0;
  21.             double howManyTickets = 0;
  22.             double howManyTicketsALL = 0;
  23.  
  24.             while (true)
  25.             {
  26.                 howManyTickets = 0;
  27.                 counterStandard = 0;
  28.                 counterKid = 0;
  29.                 counterStudent = 0;
  30.  
  31.                 movie = Console.ReadLine();
  32.                 if (movie == "Finish")
  33.                 {
  34.                     break;
  35.                 }
  36.                 howMany = int.Parse(Console.ReadLine());
  37.  
  38.                 while (true)
  39.                 {
  40.                     tickets = Console.ReadLine();
  41.                     if (tickets == "End" || tickets == "Finish")
  42.                     {
  43.                         break;
  44.                     }
  45.  
  46.                     switch (tickets)
  47.                     {
  48.                         case "standard":
  49.                             counterStandard++;
  50.                             break;
  51.                         case "kid":
  52.                             counterKid++;
  53.                             break;
  54.                         case "student":
  55.                             counterStudent++;
  56.                             break;
  57.                     }
  58.                 }
  59.                 counterStandardALL += counterStandard;
  60.                 counterKidALL += counterKid;
  61.                 counterStudentALL += counterStudent;
  62.  
  63.                 howManyTickets = counterStandard + counterKid + counterStudent;
  64.                 Console.WriteLine($"{movie} - {howManyTickets / howMany * 100:F2}% full.");
  65.                
  66.                 if (tickets == "Finish")
  67.                 {
  68.                     break;
  69.                 }
  70.             }
  71.             howManyTicketsALL = counterStandardALL + counterStudentALL + counterKidALL;
  72.             Console.WriteLine($"Total tickets: {howManyTicketsALL}");
  73.             Console.WriteLine($"{counterStudentALL / howManyTicketsALL * 100:F2}% student tickets.");
  74.             Console.WriteLine($"{counterStandardALL / howManyTicketsALL * 100:F2}% standard tickets.");
  75.             Console.WriteLine($"{counterKidALL / howManyTicketsALL * 100:F2}% kids tickets.");
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement