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

Error running TreeStory.java

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 __adjective__ __noun__. They are always __adverb__ __verb__.
String ageAsString = console.readLine("How Old are you?  ");
int age = Integer.parseInt(ageAsString);  
if (age < 13) {
  //Insert exit code
  console.printf("Sorry, age not met\n");
  System.exit (0);  
}
String name = console.readLine("Enter a name:  ");
String adjective = console.readLine("Enter an adjective:  ");
String noun = console.readLine("Enter a noun:  ");
if (noun.equalsIgnoreCase("dork")) {
  console.printf("That input is not allowed. \n\n");
  System.exit(0);
}

As the title states, I am receiving an error

TreeStory.java:27: error: reached end of file while parsing
}
^
1 error

It appears as though I have all the needed brackets, but I can not for the life of me understand what causes that error? I've tried to delete and add in several different things to make it run.

Thanks

Seems odd its pointing at the bracket. I tried to compare it to mine and couldnt find anything. Im new to this myself though so im probably not the best to answer.

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Jon;

You are missing two closing } brackets. One for public class TreeStory and one for public static void...

Adding those two brackets allowed the code to run just fine for me.

One tip I might provide is to utilize consistent indenting, it allows you to see the pairs of brackets easier, at least it does for me.

Happy coding and welcome to Treehouse.

Ken

Thank you Ken,

your help is greatly appreciated.