Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Basics Perfecting the Prototype Censoring Words - Looping Until the Value Passes

Dhruv Reddy
Dhruv Reddy
269 Points

Could somebody please check the code

//Loop

  boolean isInvalidWord;
  do { 
     noun = console.readline("Enter a noun: ");
     isInvalidWord = (noun.equalsIgnoreCase("dork")||
                              noun.equalsIgnoreCase("jerk"));

    if (isInvalidWord) {
      console.printf("That language is not allowed.  Try again.  \n\n");
    }
  } while (isInvalidWord);

  String adverb = console.readLine("Enter an adverb: ");
  String verb = console.readLine("Enter a verb ending in -ing: ");
  console.printf("%s is a %s %s.", name, adjective, noun);
  console.printf("They are always %s %s.\n", adverb, verb); 

}

} //It keeps saying that string cannot be converted into boolean for the 3rd line (showed below)

noun = console.readline("Enter a noun: ");

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Dhruv Reddy! You just have a small typo. You typed readline instead of readLine. Note that the correct method contains a capital "L". Remember that this is all case-sensitive.

Hope this helps! :sparkles: