Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.concurrent.ScheduledExecutorService;
- public class P5 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- int countToys = 0;
- int countSweaters = 0;
- int pricePerToy = 5;
- int pricePerSweater = 15;
- while (!input.equals("Christmas")) {
- int age = Integer.parseInt(input);
- if (age <= 16) {
- countToys ++;
- } else {
- countSweaters ++;
- }
- input = scanner.nextLine();
- }
- System.out.printf("Number of adults: %d%nNumber of kids: %d%nMoney for toys: %d%nMoney for sweaters: %d%n", countSweaters, countToys, countToys * pricePerToy, countSweaters * pricePerSweater);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment