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 Looping until the value passes

What am I doing wrong? Reached end of file while parsing

I was trying to copy the code used in the videos, but must have gotten some part of the syntax incorrect.

What am I missing to make the code work?

KnockKnock.java
Learning Madlibs

 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("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");
        System.exit(0);
        }
    String name = console.readLine("Enter your name:  ");
    String noun;
        boolean isInvalidWord;
        do {    
            noun = console.readLine("Enter a noun:  ");
            isInvalidWord = noun.equalsIsIgnoreCase("dork")||
                          noun.equalsIsIgnoreCase("jerk");
            if (isInvalidWord);{
                console.print("That language is not allowed. Try Again  \n\n");
        } while(isInvalidWord);
    String pronoun = console.readLine("Enter a pronoun:  ");
    String thing = console.readLine("Enter a noun:  ");
    String thing2 = console.readLine("Enter a noun:  ");
    String adjective = console.readLine("Enter an adjective:  ");      
    String time = console.readLine("Enter an amount of time:  ");
    String verb = console.readLine("Enter a verb:  ");      
    String verb2 = console.readLine("Enter a verb:  ");
    console.printf("Once upon a time there was a %s %s named %s. \n %s liked %s and %s. Every %s, %s would %s and %s. \n %s was everyone's favorite %s", adjective, noun, name, pronoun, thing, thing2, time, pronoun, verb, verb2, name, noun );
    }; 
};

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

HINT: Somewhere around if (isInvalidWord) things start getting fishy.

Megan Wood
Megan Wood
2,567 Points

Usually this error means you have some mismatched curly braces or no closing curly brace at the end of your file. Make sure each of your curly braces line up.