Advertisement
Spocoman

Christmas Gifts

Sep 3rd, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int kids = 0, adults = 0;
  7.  
  8.         String input;
  9.         while (!(input = scanner.nextLine()).equals("Christmas")) {
  10.             int years = Integer.parseInt(input);
  11.             if (years <= 16) {
  12.                 kids++;
  13.             } else {
  14.                 adults++;
  15.             }
  16.         }
  17.  
  18.         System.out.println("Number of adults: " + adults);
  19.         System.out.println("Number of kids: " + kids);
  20.         System.out.println("Money for toys: " + kids * 5);
  21.         System.out.println("Money for sweaters: " + adults * 15);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement