Advertisement
amorr

Cinema tickets

Jun 16th, 2021
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06_07_Cinema_tickets
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string movie = Console.ReadLine();
  10.             double availableSeats = double.Parse(Console.ReadLine());
  11.  
  12.             double totalTickets = 0;
  13.             double movieTickets = 0;
  14.             double studentTickets = 0;
  15.             double standardTickets = 0;
  16.             double kidsTickets = 0;
  17.  
  18.             while (movie != "Finish")
  19.             {
  20.                 string ticketType = Console.ReadLine();
  21.                 while (ticketType != "End" && movieTickets < availableSeats)
  22.                 {
  23.  
  24.                     if (ticketType == "student")
  25.                     {
  26.                         totalTickets++;
  27.                         movieTickets++;
  28.                         studentTickets++;
  29.                     }
  30.                     else if (ticketType == "standard")
  31.                     {
  32.                         totalTickets++;
  33.                         movieTickets++;
  34.                         standardTickets++;
  35.                     }
  36.                     else if (ticketType == "kid")
  37.                     {
  38.                         totalTickets++;
  39.                         movieTickets++;
  40.                         kidsTickets++;
  41.                     }
  42.  
  43.                     ticketType = Console.ReadLine();
  44.                 }
  45.  
  46.                 double moviePercent = (movieTickets / availableSeats) * 100;
  47.  
  48.                 Console.WriteLine($"{movie} - {moviePercent:f2}% full.");
  49.  
  50.                 moviePercent = 0;
  51.                 movieTickets = 0;
  52.  
  53.                 if (ticketType == "Finish")
  54.                 {
  55.                     goto Found;
  56.                 }
  57.  
  58.                 movie = Console.ReadLine();
  59.                 availableSeats = double.Parse(Console.ReadLine());
  60.             }
  61.  
  62.         Found:
  63.             double studentsPercent = (studentTickets / totalTickets * 100);
  64.             double standardsPercent = (standardTickets / totalTickets * 100);
  65.             double kidsPercent = (kidsTickets / totalTickets * 100);
  66.  
  67.             Console.WriteLine($"Total tickets: {totalTickets}");
  68.             Console.WriteLine($"{studentsPercent:f2}% student tickets.");
  69.             Console.WriteLine($"{standardsPercent:f2}% standard tickets.");
  70.             Console.WriteLine($"{kidsPercent:f2}% kids tickets.");
  71.         }
  72.     }
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement