Determining life stage based on age

Report a typo

Your task is to write a complete Java program that takes in a single line with an integer between 0-100 (inclusive) as input. This integer represents a person's age. The program should then print a message that tells the person which life stage they are in based on the following conditions:

  • If the person's age is less than 12 (inclusive), print 'Child'.

  • If the age is between 13 and 17 (both inclusive), print 'Teenager'.

  • If the age is between 18 and 59 (both inclusive), print 'Adult'.

  • Lastly, if the person's age is 60 (inclusive) or above, print 'Senior Citizen'.

Sample Input 1:

12

Sample Output 1:

Child

Sample Input 2:

13

Sample Output 2:

Teenager
Write a program in Java 17
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
// Create a Scanner object to read input
Scanner sc = new Scanner(System.in);

// Read the integer
int age = sc.nextInt();

// Write your code here to determine the life stage based on the input age
// You should use if...else if...else statement
// Then, print out the appropriate message

sc.close();
}
}
___

Create a free account to access the full topic