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

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

David Hinton
David Hinton
3,070 Points

Censoring Words - Looping Until the Value Passes

I must be getting really tired now, I can't seem to spot the problem , guess i've done too many hours straight today :(

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!
    */
  String ageAsString = console.readLine("What is your age? ");
  int age = Integer.parseInt(ageAsString);
  if (age < 13){
    console.printf("Sorry you are too young. \n");
    System.exit(0);
  }

{String name = console.readLine("Enter a name: "); String adjective = console.readLine("Enter an adjective: "); do { String noun = console.readLine("Enter a noun: "); if (noun.equalsIgnoreCase("Dork") || noun.equalsIgnoreCase("Jerk")) { console.printf("That language is not acceptable, Exiting program \n"); }while (noun.equalsIgnoreCase("Dork") || noun.equalsIgnoreCase("Jerk")); } 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 %s. \n", adverb, verb); }

The error ^

         TreeStory.java:36: error: while expected                                                                                    

TreeStory.java:36: error: reached end of file while parsing
TreeStory.java:29: error: while expected
}while (noun.equalsIgnoreCase("Dork") || noun.equalsIgnoreCase("Jerk")); }
^
TreeStory.java:30: error: ')' expected
String adverb = console.readLine("Enter an adverb: "); ^
TreeStory.java:34: error: reached end of file while parsing
console.printf("They are always %s %s. \n", adverb, verb);

The first thing you might check is placement of all of your curly brackets. Line 36 error would be your first clue that you could be missing one somewhere.

David Hinton
David Hinton
3,070 Points

Hi thanks , yeah it all got a bit jumbled up last night when I was working tired. I just started a new work and followed it carefully and no problems now