Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _06.Cinema_Tickets
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double countTickets = 0;
  14.             int allTickets = 0;
  15.             double countStandartTicket = 0;
  16.             double countStudentTicket = 0;
  17.             double countKidTicket = 0;
  18.             int freeOnesPlaces = 0;
  19.             string movieName = string.Empty;
  20.  
  21.             while (true)
  22.             {
  23.                 string input = Console.ReadLine();
  24.                 if (input == "Finish")
  25.                 {
  26.                     break;
  27.                 }
  28.                 else
  29.                 {
  30.                     movieName = input;
  31.                     freeOnesPlaces = int.Parse(Console.ReadLine());
  32.                     for (int i = 1; i <= freeOnesPlaces; i++)
  33.                     {
  34.                         string ticketType = Console.ReadLine();
  35.                         if (ticketType == "End")
  36.                         {
  37.                             Console.WriteLine($"{movieName} - {(countTickets / freeOnesPlaces) * 100:f2}% full.");
  38.                             countTickets = 0;
  39.                             break;
  40.                         }
  41.                         else
  42.                         {
  43.                             countTickets++;
  44.                             allTickets++;
  45.                             if (ticketType == "student")
  46.                             {
  47.                                 countStudentTicket++;
  48.                             }
  49.                             else if (ticketType == "standard")
  50.                             {
  51.                                 countStandartTicket++;
  52.                             }
  53.                             else if (ticketType == "kid")
  54.                             {
  55.                                 countKidTicket++;
  56.                             }
  57.                         }
  58.                         if (i == freeOnesPlaces)
  59.                         {
  60.                             Console.WriteLine($"{movieName} - {((countTickets / freeOnesPlaces) * 100):f2}% full.");
  61.                             countTickets = 0;
  62.                         }
  63.                     }
  64.                 }
  65.             }
  66.             Console.WriteLine($"Total tickets: {allTickets}");
  67.             Console.WriteLine($"{((countStudentTicket / allTickets) * 100):f2}% student tickets.");
  68.             Console.WriteLine($"{((countStandartTicket / allTickets) * 100):f2}% standard tickets.");
  69.             Console.WriteLine($"{((countKidTicket / allTickets) * 100):f2}% kids tickets.");
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement