Advertisement
Ligh7_of_H3av3n

05.ChristmasGifts

Oct 21st, 2023
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package ZadachiOtIzpita2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ChristmassGift {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int kids = 0;
  10.         int adults = 0;
  11.  
  12.         while (true) {
  13.             String x = scanner.nextLine();
  14.  
  15.             if (x.equals("Christmas")) {
  16.                 break;
  17.             }
  18.             if (Integer.parseInt(x) <= 16) {
  19.                 kids++;
  20.             } else {
  21.                 adults++;
  22.             }
  23.         }
  24.         System.out.println("Number of adults: " + adults);
  25.         System.out.println("Number of kids: " + kids);
  26.         System.out.println("Money for toys: " + kids * 5);
  27.         System.out.println("Money for sweaters: " + adults * 15);
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement