Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.izpitJecho;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- // write your code here
- Scanner scan = new Scanner(System.in);
- String end = "Christmas";
- int moneyForToys = 5;
- int moneyForSweaters = 15;
- int kids = 0;
- int adults = 0;
- int age = 0;
- String input = scan.nextLine();
- while(!(input.equals(end))){
- age = Integer.parseInt(input);
- if(age <= 16) {
- kids++;
- } else {
- adults++;
- }
- input = scan.nextLine();
- }
- 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 * kids);
- System.out.printf("Money for sweaters: %d\n", moneyForSweaters * adults);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement