IvetValcheva

06. Cinema Tickets

Dec 4th, 2021
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp17
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int studentTickets = 0;
  10.             int standardTickets = 0;
  11.             int kidTickets = 0;
  12.  
  13.             string filmName = Console.ReadLine();
  14.  
  15.             while (filmName != "Finish")
  16.             {
  17.                 int free = int.Parse(Console.ReadLine());
  18.                
  19.                 string type = Console.ReadLine();
  20.                 int ticket = 0;
  21.  
  22.                 while (type != "End")
  23.                 {
  24.                     if (type== "student")
  25.                     {
  26.                         studentTickets++;
  27.                     }
  28.                     else if (type == "standard")
  29.                     {
  30.                         standardTickets++;
  31.                     }
  32.                     else
  33.                     {
  34.                         kidTickets++;
  35.                     }
  36.                     ticket++;
  37.  
  38.                     if (ticket == free)
  39.                     {
  40.                         break;
  41.                     }
  42.  
  43.                     type = Console.ReadLine();
  44.                 }
  45.  
  46.                 //процент запълненост на залата
  47.                 double occupancy = ticket * 100.00 / free;
  48.  
  49.                 Console.WriteLine($"{filmName} - {occupancy:F2}% full.");
  50.  
  51.                 filmName = Console.ReadLine();
  52.             }
  53.  
  54.             int totalTickets = studentTickets + standardTickets + kidTickets;
  55.  
  56.             Console.WriteLine($"Total tickets: {totalTickets}");
  57.             Console.WriteLine($"{(studentTickets*100.00/ totalTickets):F2}% student tickets.");
  58.             Console.WriteLine($"{(standardTickets * 100.00 / totalTickets):F2}% standard tickets.");
  59.             Console.WriteLine($"{(kidTickets * 100.00 / totalTickets):F2}% kids tickets.");
  60.  
  61.         }
  62.     }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment