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