Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.lang.reflect.Array;
  4. import java.util.Arrays;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Scanner;
  8. import java.util.stream.Collectors;
  9.  
  10. public class a11VehiclePark {
  11. public static void main(String[] args) {
  12. Scanner Console = new Scanner(System.in);
  13. List<String> vehicles = Arrays.stream(Console.nextLine().toLowerCase().split("\\s+")).collect(Collectors.toList());
  14.  
  15.  
  16. int soldVegiclesCount = 0;
  17. while (true){
  18. String customers = Console.nextLine();
  19. if(customers.equals("End of customers!"))
  20. break;
  21. customers = customers.toLowerCase();
  22. String[] params = customers.split("\\s+");
  23. String query = params[0].charAt(0) + "" + params[2];
  24. if(vehicles.contains(query)){
  25. System.out.print("Yes, sold for ");
  26. int price = query.charAt(0) * Integer.parseInt(query.substring(1));
  27. System.out.println(price + "$");
  28. vehicles.remove(query);
  29. soldVegiclesCount++;
  30. }
  31. else
  32. System.out.println("No");
  33. }
  34.  
  35. System.out.printf("Vehicles left: %s\n", String.join(", ", vehicles));
  36. System.out.printf("Vehicles sold: %d", soldVegiclesCount);
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement