Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TechModule;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- import java.util.stream.Collectors;
- public class p04_ListsDrumSet {
- public static void main(String[] args) {
- Scanner scanner= new Scanner(System.in);
- double savings=Double.parseDouble(scanner.nextLine());
- List<Integer>drums= Arrays.stream(scanner.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());
- String power=scanner.nextLine();
- List<Integer>test=drums;
- while(!power.equals("Hit it again, Gabsy!")){
- int powerDown=Integer.parseInt(power);
- for (int i = 0; i <test.size() ; i++) {
- int a =test.get(i)-powerDown;
- test.set(i,a);
- if(a<=0 && savings>0){
- test.set(i,drums.get(i));
- savings-=(drums.get(i)*3);
- }else if(savings<0){
- test.remove(i);
- if(test.size()==0){
- break;
- }
- }
- }
- power=scanner.nextLine();
- }
- System.out.println(test.toString().replaceAll("[\\[\\]\\,]",""));
- System.out.printf("Gabsy has %.2flv.",savings);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment