Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Write a program that determines whether based on the given age a person is: baby, child, teenager, adult, elder. The bounders are:
- • 0-2 – baby;
- • 3-13 – child;
- • 14-19 – teenager;
- • 20-65 – adult;
- • >=66 – elder;
- • All the values are inclusive.
- */
- import java.util.Scanner;
- public class Ex1Ages {
- public static void main(String[] args) {
- int age = new Scanner(System.in).nextInt();
- String person;
- if (0<=age && age<=2){
- person = "baby";
- }else if (3<= age && age<=13){
- person = "child";
- }else if (14<= age && age<=19){
- person = "teenager";
- }else if (20<= age && age<=65){
- person = "adult";
- }else{
- person = "elder";
- }
- System.out.println(person);
- }
- }
Add Comment
Please, Sign In to add comment