Advertisement
galinyotsev123

ProgBasicsExam22and23December2018-E04christmasGifts

Dec 30th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E04christmasGifts {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int kids = 0;
  8. int adults = 0;
  9. int moneyForToys = 0;
  10. int moneyForSweaters = 0;
  11.  
  12. String command = scanner.nextLine();
  13.  
  14. while (!command.equalsIgnoreCase("Christmas")){
  15. int age = Integer.parseInt(command);
  16.  
  17. if (age > 16) {
  18. adults++;
  19. moneyForSweaters += 15;
  20. }
  21. else {
  22. kids++;
  23. moneyForToys+=5;
  24. }
  25. command=scanner.nextLine();
  26. }
  27.  
  28. System.out.printf("Number of adults: %d%n", adults);
  29. System.out.printf("Number of kids: %d%n", kids);
  30. System.out.printf("Money for toys: %d%n", moneyForToys);
  31. System.out.printf("Money for sweaters: %d%n", moneyForSweaters);
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement