227k views
0 votes
import java.util.Scanner; public class TeenagerDetector { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; kidAge = scnr.nextInt(); /* Your solution goes here */ if (isTeenager) { System.out.println("Teen"); } else { System.out.println("Not teen"); } } }

User The Artist
by
5.1k points

2 Answers

5 votes

Answer:

isTeenager = ( kidAge >= 13 ) && ( kidAge <= 19);

Step-by-step explanation:

import java.util.Scanner; public class TeenagerDetector { public static void main-example-1
User Cplusplusrat
by
6.1k points
5 votes

Answer:

import java.util.Scanner;

public class TeenagerDetector {

public static void main (String [] args) {

Scanner scnr = new Scanner(System.in);

boolean isTeenager;

int kidAge;

kidAge = scnr.nextInt();

/* Your solution goes here */

isTeenager = (kidAge >= 13) && (kidAge <= 19);

if (isTeenager) {

System.out.println("Teen");

} else { System.out.println("Not teen"); } } }

Step-by-step explanation:

A condition which check for the teenager age and return a boolean is assigned to isTeenager.

isTeenager = (kidAge >=13) && (kidAge <= 19);

So, if the kidAge is greater than/equal to 13 and less than/19, the boolean isTeenager will be true and the program will output "Teen" else "false" will be output.

The range of age for a teenager is 13 - 19.

User Saurabh Srivastava
by
5.2k points