Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _27ExamPreparation;
- import java.util.Scanner;
- public class _01task {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- String input = in.nextLine();
- int stacks = 0;
- int beers = 0;
- String[] temp;
- while (!input.equals("End")) {
- temp = input.split(" ");
- if (temp[1].equals("stacks")) {
- stacks += Integer.parseInt(temp[0]);
- } else
- beers += Integer.parseInt(temp[0]);
- input = in.nextLine();
- }
- if(beers>=20){
- stacks += beers/20;
- beers%=20;
- }
- System.out.println(stacks + " stacks + " + beers
- + " beers");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement