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

Nathan Jorgensen
Nathan Jorgensen
1,525 Points

TreeStory.java:30: error: reached end of file while parsing }

    public static void main(String[] args) {

  String ageAsString = console.readLine("How old are you?  ");
  int age = Integer.parseInt(ageAsString);
  if (age < 13) {
    console.printf("Sorry you must be at least 13 to use this program.\n");
    System.exit(0);
  }

  String name = console.readLine("Enter your name: ");
  String adjective = console.readLine("Enter an adjective: ");
  String noun;
  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("Your TreeStory:\n--------------\n");
  console.printf("%s is very %s", name, adjective);
  console.printf("They are always %s %s. \n", adverb, verb);
    }

3 Answers

Tom Sager
Tom Sager
18,987 Points

1) There is a "Markdown Cheatsheet" link at the bottom of this page that shows you how to post code that is readable.

2) It does not look like you are terminating your if clause:

if (age) 

not

if(age
Gi Devs
Gi Devs
12,171 Points

you exited the code after (age so you need to put the last peice ); on a new line so it would look like

if (age //insert exi. . .  Try again. \n\n"
);
Alexander Patsarikas
Alexander Patsarikas
4,588 Points

I think you should simply add a closing bracket } at the very end of your java code. So instead of

console.printf("They are always %s %s. \n", adverb, verb);
    }

you should try

console.printf("They are always %s %s. \n", adverb, verb);
    } }