Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _1_DozensOfEggs {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- int countDozens = 0;
- int countEggs = 0;
- for (int i = 0; i < 7; i++) {
- int count = scan.nextInt();
- String measure = scan.next();
- if (measure.equals("eggs")) {
- countEggs += count;
- } else {
- countDozens += count;
- }
- scan.nextLine();
- }
- if (countEggs > 11) {
- countDozens += countEggs / 12;
- countEggs %= 12;
- }
- System.out.printf("%d dozens + %d eggs%n", countDozens, countEggs);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement