Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CinemaTickets
- {
- class Program
- {
- static void Main()
- {
- int standardTicket = 0;
- int studentTicket = 0;
- int kidTicket = 0;
- int totalSeats = 0;
- int currentSeatsMovie = 0; //заети места!
- int allSeatsMovie = 0;
- string movie = Console.ReadLine();
- while (movie != "Finish")
- {
- allSeatsMovie = int.Parse(Console.ReadLine());
- string ticketType = Console.ReadLine();
- while (ticketType != "End" && currentSeatsMovie < allSeatsMovie) //изпълнените седалки не са по-малки или равни - А САМО по-малки от капацитета (allSeats) - защото в цикала имаме прибавяне ++
- {
- switch (ticketType)
- {
- case "standard":
- standardTicket++;
- break;
- case "student":
- studentTicket++;
- break;
- case "kid":
- kidTicket++;
- break;
- }
- currentSeatsMovie++;
- ticketType = Console.ReadLine();
- }
- double utilized = (double)currentSeatsMovie / (double)allSeatsMovie * 100;
- Console.WriteLine($"{movie} - {utilized:F2}% full.");
- totalSeats += currentSeatsMovie;
- currentSeatsMovie = 0; //нулираме "current seats", за да почнем от нулата при следващия филм.
- if (ticketType == "Finish")
- {
- break;
- }
- else
- {
- movie = Console.ReadLine();
- }
- }
- Console.WriteLine($"Total tickets: {totalSeats}");
- Console.WriteLine($"{((decimal)studentTicket / totalSeats * 100):F2}% student tickets.");
- Console.WriteLine($"{((decimal)standardTicket / totalSeats * 100):F2}% standard tickets.");
- Console.WriteLine($"{((decimal)kidTicket / totalSeats * 100):F2}% kids tickets.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement