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

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,831 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