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 Logical ORs

error 15 not a statement keeps popping up and my code is "age = 12";

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); "age = 12"; if (age < 13) { //insert exit code console.printf("sorry yo ass is too young\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: "); if (noun.equalsIgnoreCase("dork")) { console.printf("that language is terrible Exiting. \n\n"); System.exit(0); }

String adverb = console.readLine("Enter an adverb: "); String verb = console.readLine("Enter a verb ending with -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);

}

}

4 Answers

error 15 not a statement

Just glancing at your code, the 15 means there is an error on line 15. "not a statement" means you probably left out a semi-colon.

After putting your code in an IDE, it looks like you have an extra double quote some where near line 15:

      "age = 12"; 

double quote?

" is a double quote. ' is a single quote.

hmmm idk where though it looks like i have them all on the error code its got the up arrow on the quotation mark right before age = 12

Katrin Nitsche
Katrin Nitsche
23,462 Points

You don't need quotes around this block if you want to assign 12 to the age variable. Only wright

age = 12;

You don't need to write int in front of age because the variable is already declared so you only change its value. By the way for the example, you can remove the code line as you prompt the user to insert the age and parse in from string int. I hope this helps.

Djamal Dagirov
Djamal Dagirov
771 Points

you forgot the "INT" man

like this -> int age = 12; not age = 12;