Advertisement
Guest User

cinemaTicket

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