Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E04christmasGifts {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int kids = 0;
- int adults = 0;
- int moneyForToys = 0;
- int moneyForSweaters = 0;
- String command = scanner.nextLine();
- while (!command.equalsIgnoreCase("Christmas")){
- int age = Integer.parseInt(command);
- if (age > 16) {
- adults++;
- moneyForSweaters += 15;
- }
- else {
- kids++;
- moneyForToys+=5;
- }
- command=scanner.nextLine();
- }
- System.out.printf("Number of adults: %d%n", adults);
- System.out.printf("Number of kids: %d%n", kids);
- System.out.printf("Money for toys: %d%n", moneyForToys);
- System.out.printf("Money for sweaters: %d%n", moneyForSweaters);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement