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 Reviewing Our Feedback

Robbin Kalaamalho
Robbin Kalaamalho
1,571 Points

Some errors I'm getting even tho I'm following instructions exactly

Here's the code:

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 an __adjective__ __noun__. They're always __adverb__ __verb__.
      int age = 12;
      if (age < 13) {
        //insert exit code
        console.printf(Sorry, you must be at least 13 to use this program./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:  ");
      String adverb = console.readLine("Enter an adverb:  ");
      String verb = console.readLine("Enter a verb ending with -ing:  ");

      console.printf(Your Tree Story: );
      console.printf( "%s is a %s %s.  ', name, adjective, noun);
      console.printf("They are always %s %s.\n", adverb, verb);
    }

}

Errors upon compiling

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 an __adjective__ __noun__. They're always __adverb__ __verb__.
      int age = 12;
      if (age < 13) {
        //insert exit code
        console.printf(Sorry, you must be at least 13 to use this program./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:  ");
      String adverb = console.readLine("Enter an adverb:  ");
      String verb = console.readLine("Enter a verb ending with -ing:  ");

      console.printf(Your Tree Story: );
      console.printf( "%s is a %s %s.  ', name, adjective, noun);
      console.printf("They are always %s %s.\n", adverb, verb);
    }

}

3 Answers

Hey Robbin,

You're actually not following the instructions exactly. Like Simon Coates said, the case of your words matters in Java: e.g. Public is just a random word; public is a keyword. Also, /n is just a forward-slash and an "n;" \n represents a newline character that tells the Java compiler, "insert a new line right here." Below is the correct code up to this point in the course:

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 an __adjective__ __noun__. They're always __adverb__ __verb__.
        int age = 12;
        if (age < 13) {
         //insert exit code
         console.printf("Sorry, you must be at least 13 to use this program./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:  ");
        String adverb = console.readLine("Enter an adverb:  ");
        String verb = console.readLine("Enter a verb ending with -ing:  ");

        console.printf("Your Tree Story: ");
        console.printf( "%s is a %s %s.  ", name, adjective, noun);
        console.printf("They are always %s %s.\n", adverb, verb);
    }
}
Simon Coates
Simon Coates
28,694 Points

java may care about capitals. And strings should be in enclosed with double quotes (eg "i am a string"). The following seems to compile - i don't know if it's logically sound:

import java.io.Console;

public class Main {

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 an __adjective__ __noun__. They're always __adverb__ __verb__.
  int age = 12;
  if (age < 13) {
    //insert exit code
    console.printf("Sorry, you must be at least 13 to use this program./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:  ");
  String adverb = console.readLine("Enter an adverb:  ");
  String verb = console.readLine("Enter a verb ending with -ing:  ");

  console.printf("Your Tree Story: ");
  console.printf( "%s is a %s %s.  ", name, adjective, noun);
  console.printf("They are always %s %s.\n", adverb, verb);
}
}
Stephen Wall
PLUS
Stephen Wall
Courses Plus Student 27,294 Points

2 things I am seeing. Your console needs to be capitalized, Console console = System.console(); Here you are accessing a Console object and naming it console (lowercase). And secondly you need to enclose your console.printf statement with double quotes: console.printf("Sorry you need to be 13"); Without the quotes it won't run.