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

Peggy Rider
Peggy Rider
782 Points

I encountered end of file error. I checked to make sure I close all my curly braces

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?  ");
    int age = Integer.parseInt(ageAsString);
    if (age < 13) 
        //insert exit code
        console.printf("Sorry you must be at least 13 to use this program.\n");
    String name = console.readLine("Enter your name:  ");
    String adjective = console.readLine("Enter an adjective: ");
    String noun;
    boolean isInvalidWord;
        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 a adverb:  ");
    String verb = console.readLine("Enter a verb:  ");
    console.printf("Your TreeStory:\n_______________________\n ");
    console.printf("%s is an %s %s.", name, adjective, noun);
    console.printf("They are always %s %s.\n", adverb, verb);

2 Answers

Daniel Bell
Daniel Bell
17,178 Points

The braces around your do; while loop are incorrect. You need to close the 'do' part.

That will fix your parse error.

Lena Hand
Lena Hand
Courses Plus Student 1,575 Points

You didn't close the if statement within your do-while loop. It looks to be around line 22.