Advertisement
dentia

CountBeers

Jun 17th, 2014
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. package _27ExamPreparation;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class _01task {
  6.     public static void main(String[] args) {
  7.         Scanner in = new Scanner(System.in);
  8.         String input = in.nextLine();
  9.  
  10.         int stacks = 0;
  11.         int beers = 0;
  12.         String[] temp;
  13.  
  14.         while (!input.equals("End")) {
  15.             temp = input.split(" ");
  16.             if (temp[1].equals("stacks")) {
  17.                 stacks += Integer.parseInt(temp[0]);
  18.             } else
  19.                 beers += Integer.parseInt(temp[0]);
  20.             input = in.nextLine();
  21.         }
  22.        
  23.         if(beers>=20){
  24.             stacks += beers/20;
  25.             beers%=20;
  26.         }
  27.        
  28.         System.out.println(stacks + " stacks + " + beers
  29.                 + " beers");
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement