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

I am encountering the same error again and again.Help me out

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 fuck off");

    System.exit(0);
  }

  String yourname = console.readLine(" What is your name:  ");
  String adjective = console.readLine(" write an adjective:  ");
  String noun;
  do {
  noun = console.readLine("write a noun:  ");
  if (noun.equalsIgnoreCase("dumb") || 
    (noun.equalsIgnoreCase("jerk")) {
    console.printf("You have a small one. \n\n");
    } 

      } while((noun.equalsIgnoreCase("dick") || (noun.equalsIgnoreCase("jerk"));

  console.printf("%s is very %s. %s", yourname, adjective, noun); 

}

}

can you point out where is the mistake it keeps saying TreeStory.java:35: error: ';' expected console.printf("%s is very %s. %s", yourname, adjective, noun);

1 Answer

Emil Rais
Emil Rais
26,819 Points

Mind the language :-)

There are three small syntactical errors.

Inside your do while construct you have an if. The if condition's parentheses do not match. If you remove the open parenthesis before noun.equalsIgnoreCase("jerk") it will fix that issue.

The other two errors are inside the while portion of the do while construct. If you remove the open parenthesis before noun.equalsIgnoreCase("dick") and the open parenthesis before noun.equalsIgnoreCase("jerk") everything should compile again.

You just made my day.Thanks and yeah sorry for the language i was just playing around