jwrbg

asd

Mar 15th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. package TechModule;
  2.  
  3. import java.util.Arrays;
  4. import java.util.List;
  5. import java.util.Scanner;
  6. import java.util.stream.Collectors;
  7.  
  8. public class p04_ListsDrumSet {
  9.     public static void main(String[] args) {
  10.         Scanner scanner= new Scanner(System.in);
  11.         double savings=Double.parseDouble(scanner.nextLine());
  12.         List<Integer>drums= Arrays.stream(scanner.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());
  13.         String power=scanner.nextLine();
  14.  
  15.         List<Integer>test=drums;
  16.  
  17.         while(!power.equals("Hit it again, Gabsy!")){
  18.             int powerDown=Integer.parseInt(power);
  19.  
  20.             for (int i = 0; i <test.size() ; i++) {
  21.                int a =test.get(i)-powerDown;
  22.                test.set(i,a);
  23.                if(a<=0 && savings>0){
  24.                   test.set(i,drums.get(i));
  25.                    savings-=(drums.get(i)*3);
  26.                }else if(savings<0){
  27.                    test.remove(i);
  28.                    if(test.size()==0){
  29.                        break;
  30.                    }
  31.                }
  32.  
  33.  
  34.             }
  35.  
  36.  
  37.             power=scanner.nextLine();
  38.         }
  39.  
  40.         System.out.println(test.toString().replaceAll("[\\[\\]\\,]",""));
  41.         System.out.printf("Gabsy has %.2flv.",savings);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment