Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class VehicleParkSold
  6. {
  7. static void Main()
  8. {
  9. string[] vehicles = Console.ReadLine().Split(' ');
  10.  
  11. int count = 0;
  12. List<string> list = vehicles.ToList();
  13.  
  14. string customer = Console.ReadLine().ToLower();
  15. while (customer != "end of customers!")
  16. {
  17. string[] customerSplit = customer.Split(' ');
  18. char car = customerSplit[0][0];
  19. int seats = int.Parse(customerSplit[2]);
  20.  
  21. bool flag = true;
  22. for (int i = 0; i < vehicles.Length; i++)
  23. {
  24. int checkSeats = int.Parse(vehicles[i].Substring(1));
  25. if (vehicles[i][0] == car && seats == checkSeats)
  26. {
  27. Console.WriteLine("Yes, sold for {0}$", car * seats);
  28. list.Remove(vehicles[i]);
  29. flag = false;
  30. count++;
  31. break;
  32. }
  33. }
  34. if (flag)
  35. {
  36. Console.WriteLine("No");
  37. }
  38.  
  39. customer = Console.ReadLine().ToLower();
  40. }
  41.  
  42. Console.WriteLine("Vehicles left: " + string.Join(", ", list));
  43. Console.WriteLine("Vehicles sold: {0}", count);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement