Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package src;
- import java.util.Scanner;
- public class Will5 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //до 16 (вкл.) = деца -> играчка
- //над 16 години = възрастни -> пуловер
- int toy = 5;
- int sweater = 15;
- int countYoung = 0;
- int countOld = 0;
- int moneyForToys = 0;
- int moneyForSweaters = 0;
- boolean finish = false;
- int kids = 0;
- int adults = 0;
- String command = null;
- do{
- command = scanner.nextLine();
- if(!command.equals("Christmas")) {
- int age = Integer.parseInt(command);
- if (age <= 16) {
- kids++;
- moneyForToys += 5;
- }
- if (age > 16) {
- adults++;
- moneyForSweaters += 15;
- }
- }
- }while (!command.equals("Christmas"));
- System.out.printf("Number of adults: %d%n", adults);
- System.out.printf("Number of kids: %d%n", kids);
- System.out.printf("Money for toys: %d%n", moneyForToys);
- System.out.printf("Money for sweaters: %d%n", moneyForSweaters);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement