fbinnzhivko

04.05 Vehicle Park

Apr 21st, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. class VehicleParkSold
  5. {
  6.     static void Main()
  7.     {
  8.  
  9.         int count = 0;
  10.         List<string> list = Console.ReadLine().Split(' ').ToList();
  11.  
  12.         string customer = Console.ReadLine().ToLower();
  13.         while (customer != "end of customers!")
  14.         {
  15.             string[] customerSplit = customer.Split(' ');
  16.             char car = customerSplit[0][0];
  17.             int seats = int.Parse(customerSplit[2]);
  18.  
  19.             if (list.Contains(car + seats.ToString()))
  20.             {
  21.                 Console.WriteLine("Yes, sold for {0}$", car * seats);
  22.                 list.Remove(car + seats.ToString());
  23.                 count++;
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine("No");
  28.             }
  29.             customer = Console.ReadLine().ToLower();
  30.         }
  31.         Console.WriteLine("Vehicles left: " + string.Join(", ", list));
  32.         Console.WriteLine("Vehicles sold: {0}", count);
  33.     }
  34. }
Add Comment
Please, Sign In to add comment