Advertisement
kalin729

Will 5

Nov 15th, 2020 (edited)
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. package src;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Will5 {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner = new Scanner(System.in);
  10.         //до 16 (вкл.) = деца -> играчка
  11.         //над 16 години = възрастни -> пуловер
  12.         int toy = 5;
  13.         int sweater = 15;
  14.  
  15.         int countYoung = 0;
  16.         int countOld = 0;
  17.         int moneyForToys = 0;
  18.         int moneyForSweaters = 0;
  19.         boolean finish = false;
  20.         int kids = 0;
  21.         int adults = 0;
  22.  
  23.         String command = null;
  24.  
  25.         do{
  26.             command = scanner.nextLine();
  27.             if(!command.equals("Christmas")) {
  28.                 int age = Integer.parseInt(command);
  29.                 if (age <= 16) {
  30.                     kids++;
  31.                     moneyForToys += 5;
  32.                 }
  33.                 if (age > 16) {
  34.                     adults++;
  35.                     moneyForSweaters += 15;
  36.                 }
  37.             }
  38.            
  39.  
  40.         }while (!command.equals("Christmas"));
  41.        
  42.         System.out.printf("Number of adults: %d%n", adults);
  43.         System.out.printf("Number of kids: %d%n", kids);
  44.         System.out.printf("Money for toys: %d%n", moneyForToys);
  45.         System.out.printf("Money for sweaters: %d%n", moneyForSweaters);
  46.        
  47.     }
  48.  
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement