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! While you're at it, check out some resources Treehouse students have shared here.
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

Sandy Woods
1,082 PointsJava String contains method
I'm trying to use the java String contains method to make a list of banned words. I also want to lower the case of each world in order to properly check to see if the word is in my list. I'm having problems on line 53, 54 and 58. Can you help me?
import java.io.Console;
public class TreeStory {
public static void main(String[] args) {
Console console = System.console();
/* Some terms:
noun - Person, place or thing
verb - An action
adjective - A description used to modify or describe a noun
Enter your amazing code here!
*/
// [Name] is a(n) [adjective] [noun]. They are always [adverb] and [verb]ing.
String ageAsString = console.readLine("How old are you? ");
int age = Integer.parseInt(ageAsString);
if (13 < age) {
//Insert exit code
console.printf("Sorry, you must be 13 or younger to use this program. \n");
System.exit(0);
}
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective: ");
String noun;
boolean isInvalidNoun;
do{
noun = console.readLine("Enter a noun: ");
isInvalidNoun =(noun.equalsIgnoreCase("nigger")||
noun.equalsIgnoreCase("coon")||
noun.equalsIgnoreCase("dork")||
noun.equalsIgnoreCase("jerk"));
if (isInvalidNoun) {
console.printf("That language is not allowed. Frick OFF....lil bih! \n\n");
}
}
while(isInvalidNoun);
String adverb;
boolean isInvalidAdverb;
do {
adverb = console.readLIne("Enter an adverb: ");
isInvalidAdverb = (adverb.contains("bitCh"));
if(isInvalidAdverb){
console.printf("That language is not allowed. Frick OFF....lil bih! \n\n");
}
}
while(isInvalidAdverb);
}
String verb = console.readLine("Enter a verb ending in -ing: ");
console.printf("Your TreeStory:\n---------\n");
console.printf("%s is a(n) %s %s ", name, adjective, noun);
console.printf("He is always %s %s. ", adverb, verb);
}
}
1 Answer

Jason Anello
Courses Plus Student 94,610 PointsHi Sandy,
On line 50 you have an extra closing curly brace.
} // Delete this curly brace
String verb = console.readLine("Enter a verb ending in -ing: ");
That one would be closing off your main method too early.
Also, on line 42, the readLine
has a capital 'I' and should be lower case 'i'. This is the one that's asking for an adverb.
The program compiled after I fixed those 2 things.

Sandy Woods
1,082 PointsThank you. And the best moderator award goes to you Jason.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 Pointsfixed code formatting