Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ZadachiOtIzpita2;
- import java.util.Scanner;
- public class ChristmassGift {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int kids = 0;
- int adults = 0;
- while (true) {
- String x = scanner.nextLine();
- if (x.equals("Christmas")) {
- break;
- }
- if (Integer.parseInt(x) <= 16) {
- kids++;
- } else {
- adults++;
- }
- }
- System.out.println("Number of adults: " + adults);
- System.out.println("Number of kids: " + kids);
- System.out.println("Money for toys: " + kids * 5);
- System.out.println("Money for sweaters: " + adults * 15);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement