CoineTre

JF-ExcBasic01. Ages

Jan 14th, 2021 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. /*Write a program that determines whether based on the given age a person is: baby, child, teenager, adult, elder. The bounders are:
  2. • 0-2 – baby;
  3. • 3-13 – child;
  4. • 14-19 – teenager;
  5. • 20-65 – adult;
  6. • >=66 – elder;
  7. • All the values are inclusive.
  8. */
  9.  
  10. import java.util.Scanner;
  11.  
  12. public class Ex1Ages {
  13.     public static void main(String[] args) {
  14.         int age = new Scanner(System.in).nextInt();
  15.         String person;
  16.         if (0<=age && age<=2){
  17.            person = "baby";
  18.         }else if (3<= age && age<=13){
  19.             person = "child";
  20.         }else if (14<= age && age<=19){
  21.             person = "teenager";
  22.         }else if (20<= age && age<=65){
  23.             person = "adult";
  24.         }else{
  25.             person = "elder";
  26.         }
  27.         System.out.println(person);
  28.     }
  29. }
Add Comment
Please, Sign In to add comment