Guest User

Untitled

a guest
Aug 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2.  
  3. namespace darkinjector {
  4. class Program {
  5. static void Main(string[] args) {
  6. bool[] seats = { false, false, false, false, false, false, false, false, false, false };
  7. int count = 0;
  8. while (count < seats.Length) {
  9. Console.Write("B, E or X: ");
  10. string input = Console.ReadLine();
  11. if (input.Length == 0) continue;
  12. char c = input.ToUpper()[0];
  13. int start;
  14. if (c == 'B')
  15. start = 0;
  16. else if (c == 'E')
  17. start = 4;
  18. else if (c == 'X')
  19. break;
  20. else
  21. continue;
  22. if (start == -1) break;
  23. while (seats[start]) start = (start + 1) % seats.Length;
  24. seats[start] = true;
  25. string seatName = start >= 4 ? "Economy" : "Business";
  26. Console.WriteLine("You were given seat {0} ({1})", start, seatName);
  27. count++;
  28. }
  29. for (int i = 0; i < seats.Length; i++) {
  30. Console.WriteLine(seats[i]);
  31. }
  32. }
  33. }
  34. }
Add Comment
Please, Sign In to add comment