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

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.