Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

colia
720 PointsTreeStory.Java - Stage 3. if (age < 13) {//Sorry you must be 13} Even if I put 18, it still runs the block of code.
Why do I keep getting this output even if the age is over 13?
How old are you? 18 Sorry you must be at least 13 to use this program.
String ageAsString = console.readLine("How old are you? ");
int age = Integer.parseInt(ageAsString);
if (age < 13); {
//Insert exit code
console.printf("Sorry, you must be at least 13 to use this program.\n");
System.exit(0);
}
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: "); String noun = console.readLine("Enter a noun: "); String adverb = console.readLine("Enter an adverb: "); String verb = console.readLine("Enter a verb ending with -ing: ");
console.printf("Your TreeStory:\n----------\n");
console.printf("%s is a %s %s", name, adjective, noun);
console.printf("They are always %s.\n", adverb, verb);
}
}
2 Answers

matsum0t0
12,520 PointsHello, try checking your- if (age < 13); {blah.blah} statement. My story runs with out the semicolon after (age<13). hope it works for you.

colia
720 Pointshaha, thats silly of me, but unfortunately its still giving me that output. Thanks, though.

colia
720 Pointshaha, thats silly of me, but unfortunately its still giving me that output. Thanks, though.
colia
720 Pointscolia
720 PointsUpdate: I do not think its an error in my code, but in workspace, as I tried to copy and paste it from online that everyone says works fine, and its giving the same error. I tried relaunching workspace as well, but to no avail.