Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class VehicleParkSold
- {
- static void Main()
- {
- string[] vehicles = Console.ReadLine().Split(' ');
- int count = 0;
- List<string> list = vehicles.ToList();
- string customer = Console.ReadLine().ToLower();
- while (customer != "end of customers!")
- {
- string[] customerSplit = customer.Split(' ');
- char car = customerSplit[0][0];
- int seats = int.Parse(customerSplit[2]);
- bool flag = true;
- for (int i = 0; i < vehicles.Length; i++)
- {
- int checkSeats = int.Parse(vehicles[i].Substring(1));
- if (vehicles[i][0] == car && seats == checkSeats)
- {
- Console.WriteLine("Yes, sold for {0}$", car * seats);
- list.Remove(vehicles[i]);
- flag = false;
- count++;
- break;
- }
- }
- if (flag)
- {
- Console.WriteLine("No");
- }
- customer = Console.ReadLine().ToLower();
- }
- Console.WriteLine("Vehicles left: " + string.Join(", ", list));
- Console.WriteLine("Vehicles sold: {0}", count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement