Advertisement
aggressiveviking

Untitled

Feb 15th, 2020
1,244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _07.CinemaTickets
  4. {
  5.     class CinemaTickets
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string filmname = Console.ReadLine();
  10.                        
  11.             double totalKids = 0;
  12.             double totalStudents = 0;
  13.             double totalStandard = 0;
  14.             double totalTickets = 0;
  15.  
  16.             while (filmname != "Finish")
  17.             {
  18.                 int kids = 0;
  19.                 int students = 0;
  20.                 int standard = 0;
  21.  
  22.                 double freeSeats = int.Parse(Console.ReadLine());
  23.  
  24.                 for (int currentSeat = 1; currentSeat <= freeSeats; currentSeat++)
  25.                 {
  26.                     string ticketType = Console.ReadLine();
  27.  
  28.                     if (ticketType == "kid")
  29.                     {
  30.                         kids++;
  31.                     }
  32.                     else if (ticketType == "student")
  33.                     {
  34.                         students++;
  35.                     }
  36.                     else if (ticketType == "standard")
  37.                     {
  38.                         standard++;
  39.                     }
  40.                     else if (ticketType == "End")
  41.                     {
  42.                         break;
  43.                     }                                        
  44.                 }
  45.  
  46.                 totalKids += kids;
  47.                 totalStudents += students;
  48.                 totalStandard += standard;
  49.  
  50.                 double percentFull = ((students + standard + kids) / freeSeats * 100);
  51.  
  52.                 Console.WriteLine($"{filmname} - {percentFull:f2}% full.");
  53.                 filmname = Console.ReadLine();
  54.  
  55.             }
  56.  
  57.             totalTickets = totalStandard + totalStudents + totalKids;
  58.             Console.WriteLine($"Total tickets: {totalTickets}");
  59.             Console.WriteLine($"{((totalStudents / totalTickets) * 100):f2}% student tickets.");
  60.             Console.WriteLine($"{((totalStandard / totalTickets) * 100):f2}% standard tickets.");
  61.             Console.WriteLine($"{((totalKids / totalTickets) * 100):f2}% kids tickets.");
  62.  
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement