Advertisement
desislava_topuzakova

01. Ages

May 21st, 2022
709
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ages_01 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //1. възраст -> входни данни
  7.         int age = Integer.parseInt(scanner.nextLine());
  8.         //2. проверка за възрастта
  9.         if (age >= 0 && age <= 2) {
  10.             System.out.println("baby");
  11.         } else if (age >= 3 && age <= 13) {
  12.             System.out.println("child");
  13.         } else if (age >= 14 && age <= 19) {
  14.             System.out.println("teenager");
  15.         } else if (age >= 20 && age <= 65) {
  16.             System.out.println("adult");
  17.         } else if (age >= 66) {
  18.             System.out.println("elder");
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement