Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace P06_CinemaTickets
- {
- class Program
- {
- static void Main()
- {
- int totalTicketsForDay = 0;
- int studentTickets = 0;
- int standardTickets = 0;
- int kidTickets = 0;
- string input = "";
- while (input != "Finish")
- {
- input = Console.ReadLine(); // "Kit"
- if(input == "Finish")
- {
- break;
- }
- string filmTitle = input;
- int seatsAvailable = int.Parse(Console.ReadLine());
- int currentAvailSeats = seatsAvailable;
- int tickSoldForFilm = 0;
- string ticketType = "";
- while (ticketType != "End" && currentAvailSeats > 0)
- {
- ticketType = Console.ReadLine();
- if(ticketType == "End")
- {
- break;
- }
- tickSoldForFilm++;
- totalTicketsForDay++;
- currentAvailSeats--;
- switch(ticketType)
- {
- case "standard":
- standardTickets++;
- break;
- case "student":
- studentTickets++;
- break;
- case "kid":
- kidTickets++;
- break;
- }
- }
- double percentageFull = tickSoldForFilm / (seatsAvailable * 1.0) * 100;
- Console.WriteLine($"{filmTitle} - {percentageFull:f2}% full.");
- }
- Console.WriteLine($"Total tickets: {totalTicketsForDay}");
- double percStudents = studentTickets / (totalTicketsForDay * 1.0) * 100;
- Console.WriteLine($"{percStudents:f2}% student tickets.");
- double percStandard = standardTickets / (totalTicketsForDay * 1.0) * 100;
- Console.WriteLine($"{percStandard:f2}% standard tickets.");
- double percKids = kidTickets / (totalTicketsForDay * 1.0) * 100;
- Console.WriteLine($"{percKids:f2}% kids tickets.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement