Advertisement
remote87

2

Apr 24th, 2021
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. package com.izpitJecho;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.     // write your code here
  9.         Scanner scan = new Scanner(System.in);
  10.  
  11.         String end = "Christmas";
  12.         int moneyForToys = 5;
  13.         int moneyForSweaters = 15;
  14.         int kids = 0;
  15.         int adults = 0;
  16.         int age = 0;
  17.  
  18.         String input = scan.nextLine();
  19.  
  20.         while(!(input.equals(end))){
  21.             age = Integer.parseInt(input);
  22.             if(age <= 16) {
  23.                 kids++;
  24.             } else {
  25.                 adults++;
  26.             }
  27.             input = scan.nextLine();
  28.         }
  29.  
  30.         System.out.printf("Number of adults: %d\n", adults);
  31.         System.out.printf("Number of kids: %d\n", kids);
  32.         System.out.printf("Money for toys: %d\n", moneyForToys * kids);
  33.         System.out.printf("Money for sweaters: %d\n", moneyForSweaters * adults);
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement