Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Write a program that prompts the user for their age and determines if they are a teenager. Someone is a teenager if their age is greater than or equal to 13 and less than or equal to 19.

Your program should be able to produce the following result:

What is your age? 13
Yes, you are a teenager.
What is your age? 17
Yes, you are a teenager.
What is your age? 20
No, you are not a teenager.
Hint: you must print either "yes" or "no" in your output.

What I have tried:

function start(){
var age = readInt("Age: ");
if(age == 20){
println("Yes, you are a teenager.");
println("No, you are not a teenager.")
Updated 28-Mar-22 20:06pm
Dave Kreskowiak 28-Mar-22 22:03pm    
And you had a question to ask?

About the only thing I'm going to tell you is what you're checking for in that if statement is wrong.

1 solution

Have a look at Java If ... Else[^].
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900