Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CinemaTickets
- {
- class Program
- {
- static void Main(string[] args)
- {
- string movieName = string.Empty;
- int spareSeats = 0;
- string ticketType = string.Empty;
- int countStudent = 0;
- int countStandard = 0;
- int countKid = 0;
- int sumTicketsPerMovie = 0;
- int sumTotalStudentTickets = 0;
- int sumTotalStandardTickets = 0;
- int sumTotalKidTickets = 0;
- while (movieName != "Finish")
- {
- sumTicketsPerMovie = 0;
- countStudent = 0;
- countStandard = 0;
- countKid = 0;
- ticketType = string.Empty;
- movieName = Console.ReadLine();
- if (movieName == "Finish")
- {
- break;
- }
- spareSeats = int.Parse(Console.ReadLine());
- while (ticketType != "End")
- {
- ticketType = Console.ReadLine();
- if (ticketType == "End")
- {
- break;
- }
- if (ticketType == "student")
- {
- countStudent++;
- sumTotalStudentTickets++;
- }
- else if (ticketType == "standard")
- {
- countStandard++;
- sumTotalStandardTickets++;
- }
- else if (ticketType == "kid")
- {
- countKid++;
- sumTotalKidTickets++;
- }
- sumTicketsPerMovie = countStudent + countStandard + countKid;
- if (sumTicketsPerMovie >= spareSeats)
- {
- break;
- }
- }
- Console.WriteLine($"{movieName} - {(sumTicketsPerMovie * 1.0 * 100 / spareSeats):f2}% full.");
- }
- int sumTotalTickets = sumTotalStudentTickets + sumTotalStandardTickets + sumTotalKidTickets;
- double procentageStudent = sumTotalStudentTickets * 1.0 * 100 / sumTotalTickets;
- double procentageStandard = sumTotalStandardTickets * 1.0 * 100 / sumTotalTickets;
- double procentageKid = sumTotalKidTickets * 1.0 * 100 / sumTotalTickets;
- Console.WriteLine($"Total tickets: {sumTotalTickets}");
- Console.WriteLine($"{procentageStudent:f2}% student tickets.");
- Console.WriteLine($"{procentageStandard:f2}% standard tickets.");
- Console.WriteLine($"{procentageKid:f2}% kids tickets.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement