Facebook
From Soft Meerkat, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 328
  1. Едно решение на 07. Cinema Tickets на C#
  2.  
  3.  
  4.  
  5. using System;
  6.  
  7. namespace CinemaTickets
  8. {
  9.     class CinemaTickets
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string command = Console.ReadLine();
  14.  
  15.             double countStandardTickets = 0;
  16.             double countStudentTickets = 0;
  17.             double countKidTickets = 0;
  18.             while (command!="Finish")
  19.             {
  20.                 int seats = int.Parse(Console.ReadLine());
  21.                 double soldTickets = 0;
  22.                 for (int i = 1; i <= seats; i++)
  23.                 {
  24.                     string seatType = Console.ReadLine();
  25.                     if (seatType == "End")
  26.                     {
  27.                         break;
  28.                     }
  29.                     else if (seatType == "student")
  30.                     {
  31.                         countStudentTickets++;
  32.                     }
  33.                     else if (seatType == "standard")
  34.                     {
  35.                         countStandardTickets++;
  36.                     }
  37.                     else if (seatType == "kid")
  38.                     {
  39.                         countKidTickets++;
  40.                     }
  41.                     soldTickets++;
  42.                 }
  43.                 Console.WriteLine($"{command} - {(soldTickets/ seats)*100:f2}% full.");
  44.                 command = Console.ReadLine();
  45.             }
  46.             double countTotalTickets = countStandardTickets + countStudentTickets + countKidTickets;
  47.             Console.WriteLine($"Total tickets: {countTotalTickets}");
  48.             Console.WriteLine($"{countStudentTickets / (countStandardTickets + countStudentTickets + countKidTickets)* 100:f2}% student tickets.");
  49.             Console.WriteLine($"{countStandardTickets / (countStandardTickets + countStudentTickets + countKidTickets) * 100:f2}% standard tickets.");
  50.             Console.WriteLine($"{countKidTickets / (countStandardTickets + countStudentTickets + countKidTickets) * 100:f2}% kids tickets.");
  51.         }
  52.     }
  53. }