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

End of file while parsing error

I'm creating a do while loop in my TreeStory while following the lesson, but when I run it (after compiling) it gives me the "end of file while parsing" error. My code looks like this: import java.io.Console;

public class TreeStory {

public static void main(String[] args) {
    Console console = System.console();
  String ageAsString = console.readLine("How old are you? \n\n");
  int age =Integer.parseInt(ageAsString);
    if (age < 13) {
    console.printf("Sorry. This is NOT for you. Exiting...\n\n");
      System.exit(0);
    }
  String name = console.readLine("Enter your name:  \n");
  String verb = console.readLine("Enter a verb ending in -ing:   \n");
  String adverb = console.readLine("Enter an adverb:    \n");
  String adjective = cosole.readLine("Enter an adjective:   \n");
  String noun;
      do {
       noun = console.readLine("Enter a noun:   \n");
        boolean isInvalidWord = (noun.equalsIgnoreCase("dork") || noun.equalsIgnoreCase("jerk"));       
       if (noun.equalsIgnoreCase("jerk") ||
      noun.equalsIgnoreCase("dork")) {
    console.printf("That language is not allowed. Try again. \n\n");
  } while(noun.equalsIgnoreCase("jerk") || noun.equalsIgnoreCase("dork"));
  console.printf("%s is %s %s at %s %s .", name, adverb, verb, adjective, noun); 
      }
       ^

It says that the error is at the end in that little curly brace at the end (see above) How would I fix this?

1 Answer

It means that you're missing a curly brace, the way you formatted your code here on the forums is a complete mess, but my guess is that you're missing the closing curly brace for the class itself. Try adding a curly brace to the end of your code and see if the compiler still gives you an error message.