Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06._Cinema_Tickets
- {
- class Program
- {
- static void Main(string[] args)
- {
- string movieName = "";
- int students = 0;
- int standards = 0;
- int kids = 0;
- int totalTicketsBought = students + standards + kids;
- while ((movieName = Console.ReadLine()) != "Finish")
- {
- int freeSpaces = int.Parse(Console.ReadLine());
- int ticketsBought = 0;
- for (int i = 0; i < freeSpaces; i++)
- {
- string typeOfTicket = Console.ReadLine();
- if (typeOfTicket == "End")
- {
- break;
- }
- switch (typeOfTicket)
- {
- case "student":
- students++;
- ticketsBought++;
- break;
- case "standard":
- standards++;
- ticketsBought++;
- break;
- case "kid":
- kids++;
- ticketsBought++;
- break;
- }
- }
- double percentageOccupied = (ticketsBought / freeSpaces) * 100;
- Console.WriteLine($"{movieName} - {percentageOccupied:f2}% full.");
- }
- Console.WriteLine($"Total tickets: {totalTicketsBought}" + Environment.NewLine + $"{students / totalTicketsBought * 100}% student tickets." + Environment.NewLine + $"{standards / totalTicketsBought * 100}% standard tickets." + Environment.NewLine + $"{kids / totalTicketsBought * 100}% kids tickets.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement