Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _1_CountBeers {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- String inputLine = scan.nextLine().trim();
- int countStacks = 0;
- int countBeers = 0;
- String[] inputs;
- while (!inputLine.equals("End")) {
- inputs = inputLine.split(" ");
- int count = Integer.parseInt(inputs[0]);
- if (inputs[1].equals("beers")) {
- countBeers += count;
- } else {
- countStacks += count;
- }
- inputLine = scan.nextLine().trim();
- }
- if (countBeers >= 20) {
- countStacks += countBeers / 20;
- countBeers %= 20;
- }
- System.out.printf("%d stacks + %d beers%n", countStacks, countBeers);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement