Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
1,287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06._Cinema_Tickets
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string movie = Console.ReadLine();
  10.             byte numStudent = 0;
  11.             byte numStandard = 0;
  12.             byte numKid = 0;
  13.             while (movie != "Finish")
  14.             {
  15.                 byte seats = byte.Parse(Console.ReadLine());
  16.                 byte movieTickets = 0;
  17.                 for (int i = 0; i < seats; i++)
  18.                 {
  19.                     string seatType = Console.ReadLine();
  20.                     if (seatType == "End")
  21.                     {
  22.                         break;
  23.                     }
  24.                     else if (seatType == "student")
  25.                     {
  26.                         numStudent++;
  27.                     }
  28.                     else if (seatType == "standard")
  29.                     {
  30.                         numStandard++;
  31.                     }
  32.                     else if (seatType == "kid")
  33.                     {
  34.                         numKid++;
  35.                     }
  36.                     movieTickets++;
  37.                 }
  38.                 Console.WriteLine($"{movie} - {(float)movieTickets / seats * 100:f2}% full.");
  39.                 movie = Console.ReadLine();
  40.             }
  41.             int totalTickets = numStudent + numStandard + numKid;
  42.             string output = string.Format($"Total tickets: {totalTickets}\n" +
  43.                 $"{(float)numStudent / totalTickets * 100f:f2}% student tickets.\n" +
  44.                 $"{(float)numStandard / totalTickets * 100f:f2}% standard tickets.\n" +
  45.                 $"{(float)numKid/totalTickets * 100f:f2}% kids tickets.");
  46.             Console.WriteLine(output);
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement