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

matt hackney
matt hackney
380 Points

Help with Treestory.java

i need help! cant figure out the errors : Identifier needed and class, interface or enum needed

here is the code

TreeStory.java
import java.io.Console;
 public class TreeStory {

   int age = 12;
   if (age < 13) {
     //insert exit code
     Console.printf ("sorry, you must be at least 13 to use this.\n")
    system.exit(0);   
   }
   String name = console.readLine("enter a name:    ");
String adjective = console.readLine("enter an adjective:    ");
String noun = console.readLines("enter a noun:    ");
String adverb = console.readLines("enter an adjective:    ");
String verb = console.readLine("enter a verb ending in -ing:    ";
console.printf("Your TreeStory:\n------------------------\n");
console.printf("%s is a %s %s. ", name adjective, noun);
console.printf ("they are always %s %s.\n", adverb, verb);
matt hackney
matt hackney
380 Points

(the structure changed when i pasted the code to the forum)

I edited your post matt hackney to add syntax highlighting and preserve whitespace. :)

4 Answers

I think you might be missing a semicolon after your console.printf line:

Console.printf ("sorry, you must be at least 13 to use this.\n")
Michael Hess
Michael Hess
24,511 Points

String verb = console.readLine("enter a verb ending in -ing: ";

It looks like you're missing a right parenthesis bracket, too.

Try: String verb = console.readLine("enter a verb ending in -ing: ");

Yep, that too.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

I think you accidentally removed the main method....

TreeStory.java
import java.io.Console;
public class TreeStory {
    //Missing this
    public static void main(String[] args) {
       //your code here
       //...
    // Need to close
    }
// Need to close
}