Advertisement
dentia

CountBeers

Jun 17th, 2014
309
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement