SHARE
TWEET

train

a guest Feb 23rd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ListsExercise;
  2.  
  3. import java.text.DecimalFormat;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. import java.util.Scanner;
  7. import java.util.stream.Collectors;
  8.  
  9. public class Train {
  10.     public static void main(String[] args) {
  11.         Scanner scanner = new Scanner(System.in);
  12.  
  13.         List<Integer> passengers = Arrays.stream(scanner.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());
  14.         int maxCountPassengers = Integer.parseInt(scanner.nextLine());
  15.  
  16.         String[] input = scanner.nextLine().split(" ");
  17.         while (!input[0].equals("e")){
  18.  
  19.             if (input[0].equals("A")){
  20.                 int inputNum = Integer.parseInt(input[1]);
  21.                 passengers.add(inputNum);
  22.             }
  23.             else {
  24.                 for (int j = 0; j < input.length; j++) {
  25.                     int inputNum = Integer.parseInt(input[j]);
  26.                     for (int i = 0; i < passengers.size(); i++) {
  27.  
  28.                         if (passengers.set(i, inputNum) <= maxCountPassengers) {
  29.                             passengers.set(i, inputNum);
  30.                         }
  31.                     }
  32.                 }
  33.             }
  34.             input = scanner.nextLine().split(" ");
  35.         }
  36.         for (int passengre : passengers) {
  37.             System.out.print(passengre + " ");
  38.         }
  39.         }
  40.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top