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 - Using String Equality

Cory Carlson
Cory Carlson
5,275 Points

I'm getting errors from code that is exactly as it is shown in the video.

It says line 28 is where the bad code is. I am lost,

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 howOld = console.readLine("How old are you:  ");
      int age = Integer.parseInt(howOld);
      if (age < 13) {
        //Insert exit code
        console.printf("Sorry you must be atleast 13 years of age to run this program\n");
        System.exit(0);
      }
      String name = console.readLine("What is your name?  ");
      String lastName = console.readLine("Also what is your last name?  ");
      String friendName = console.readLine("What is your friends name?  ");
      if (friendName.equals("dork")) {
      console.printf("Sorry but you cannot name your friend dork\n\n");
      System.exit(0);
      }
      String favFoodOne = console.readLine("What is your favorite food?  ");
      String favFoodTwo = console.readLine("Name another one.  ");
      console.printf("%s %s is a cool name and\n", name, lastName);
      console.printf("%s seems like a very cool guy\n", friendName);
      console.printf("Never tried %s, although it seems good and so does %s", favFoodOne, favFoodTwo);
    }

}

I just tried your code in Workspaces and it works just fine. What error are you getting?

Cory Carlson
Cory Carlson
5,275 Points

It was saying it expected a ";" at the end of this:

console.printf("%s %s is a cool name and\n", name, lastName);

I deleted the work space and loaded the default and everything works now.