Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.72 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.                     //Console.WriteLine($"{movieName} - {(countTickets / freeOnesPlaces) * 100:f2}% full.");
  27.                     break;
  28.                 }
  29.                 else
  30.                 {
  31.                     movieName = input;
  32.                     freeOnesPlaces = int.Parse(Console.ReadLine());
  33.                     for (int i = 1; i <= freeOnesPlaces; i++)
  34.                     {
  35.                         string ticketType = Console.ReadLine();
  36.                         if (ticketType == "End")
  37.                         {
  38.                             Console.WriteLine($"{movieName} - {(countTickets / freeOnesPlaces) * 100:f2}% full.");
  39.                             countTickets = 0;
  40.                             break;
  41.                         }
  42.                         else
  43.                         {
  44.                             countTickets++;
  45.                             allTickets++;
  46.                             if (ticketType == "student")
  47.                             {
  48.                                 countStudentTicket++;
  49.                             }
  50.                             else if (ticketType == "standard")
  51.                             {
  52.                                 countStandartTicket++;
  53.                             }
  54.                             else if (ticketType == "kid")
  55.                             {
  56.                                 countKidTicket++;
  57.                             }
  58.                         }
  59.                         if (i == freeOnesPlaces)
  60.                         {
  61.                             Console.WriteLine($"{movieName} - {(countTickets / freeOnesPlaces) * 100:f2}% full.");
  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