Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.ArrayList;
- public class Problem1 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- ArrayList<String> inputList = new ArrayList<>();
- boolean ended = true;
- while (ended) {
- String temp = scan.nextLine();
- if (temp.equals("End")) {
- ended = false;
- }
- inputList.add(temp);
- }
- int beers = 0;
- int stacks = 0;
- //System.out.println(inputList.get(0));
- String[] temp = new String[2];
- for (int i = 0; i < inputList.size()-1; i++) {
- temp=inputList.get(i).split(" ");
- if (temp[1].equals("stacks")) {
- stacks += Integer.parseInt(temp[0]);
- }else{
- beers += Integer.parseInt(temp[0]);
- }
- }
- if (beers>20) {
- stacks += beers / 20;
- beers = beers %20;
- }
- System.out.println(stacks + " stacks + " + beers + " beers");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement