Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.57 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 ConsoleApp32
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string movieOrFinish = Console.ReadLine();
  14.             double availableSeats = double.Parse(Console.ReadLine());
  15.             string typeSeats = "";
  16.  
  17.             double student = 0;
  18.             double standard = 0;
  19.             double kid = 0;
  20.  
  21.             double totalseatsCounter = 1;
  22.  
  23.             bool check = true;
  24.  
  25.             double studentPercent = 0;
  26.             double standardPercent = 0;
  27.             double kidPercent = 0;
  28.  
  29.             while (movieOrFinish != "Finish")
  30.             {
  31.  
  32.                 for (int counter = 1; counter <= availableSeats; counter++)
  33.                 {
  34.                     typeSeats = Console.ReadLine();
  35.                     if (typeSeats == "student")
  36.                     {
  37.                         student++;
  38.                         studentPercent++;
  39.                     }
  40.                     else if (typeSeats == "standard")
  41.                     {
  42.                         standard++;
  43.                         standardPercent++;
  44.                     }
  45.                     else if (typeSeats == "kid")
  46.                     {
  47.                         kid++;
  48.                         kidPercent++;
  49.                     }
  50.  
  51.                     if (typeSeats == "End" || counter == availableSeats)
  52.                     {
  53.                         double percent = (student + standard + kid) / availableSeats * 100;
  54.                         Console.WriteLine($"{movieOrFinish} - {percent:f2}% full. ");
  55.                         student = 0;
  56.                         standard = 0;
  57.                         kid = 0;
  58.                         counter = 0;
  59.                         break;
  60.                     }
  61.                     totalseatsCounter++;
  62.                 }
  63.                 movieOrFinish = Console.ReadLine();
  64.                 if (movieOrFinish == "Finish")
  65.                 {
  66.                     Console.WriteLine($"Total tickets: {totalseatsCounter}");
  67.                     Console.WriteLine($"{(studentPercent / totalseatsCounter * 100):F2}% student tickets.");
  68.                     Console.WriteLine($"{(standardPercent / totalseatsCounter * 100):F2}% standard tickets.");
  69.                     Console.WriteLine($"{(kidPercent / totalseatsCounter * 100):F2}% kids tickets.");
  70.  
  71.                 }
  72.  
  73.  
  74.  
  75.                 availableSeats = double.Parse(Console.ReadLine());
  76.  
  77.  
  78.             }
  79.  
  80.  
  81.         }
  82.  
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement