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 trialTinashe Nyandoro
564 PointsI am encountering errors upon running the complier when I have followed the steps to censor words.
TreeStory.java:25: error: illegal start of expression
if (noun.equalsIgnoreCase("dork")) ||
^
TreeStory.java:26: error: ';' expected
(noun.equalsIgnoreCase("jerk")) {
^
TreeStory.java:29: error: ';' expected
} while (noun.equalsIgnoreCase("dork")) || noun.equalsIgnoreCase("jerk");
^
TreeStory.java:37: error: reached end of file while parsing
}
^
4 errors
6 Answers
akiva grobman
9,160 PointsThe line should be like this Console.printf("They are always %s %s. \n", adverb, verb) ;
Tinashe Nyandoro
564 PointsThank you Akiva. It worked
akiva grobman
9,160 PointsFrom what you have posted it seems like your || are not in the if statement
akiva grobman
9,160 PointsYou seam to be missing a closing bracket fot the if(age <13) And you have an unnecessary bracket on the last console.printf
Tinashe Nyandoro
564 PointsThank you. i have added a closing bracket on (age < 13). Removed the bracket you said is unnecessary but i have encountered an error in the console that says
Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:38: error: reached end of file while parsing
console.printf("They are always %s %s.\n, adverb, verb");
^
1 error
akiva grobman
9,160 PointsGlad I could help
Aaron Choe
1,505 Pointsnot sure if someone helped you with your recent error. But,
Unedited: console.printf("They are always %s %s.\n, adverb, verb");
the fix should be to add "
Edited: console.printf("They are always %s %s.\n", adverb, verb");
Tinashe Nyandoro
564 PointsThank you Kris the full code below:
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 a __adjective__ __noun__. They are always __adverb__ __verb__.
String ageAsString = console.readLine("How old are you? ");
int age = Integer.parseInt(ageAsString);
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;
do {
String noun = console.readLine("Enter a noun: ");
if (noun.equalsIgnoreCase("dork")) ||
(noun.equalsIgnoreCase("jerk")) {
console.printf("That language is not allowed. Try again. \n\n");
}
} while (noun.equalsIgnoreCase("dork")) || noun.equalsIgnoreCase("jerk");
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"); {
}
KRIS NIKOLAISEN
54,971 PointsKRIS NIKOLAISEN
54,971 Pointsillegal start of expression usually means looking at preceding lines of code. Can you post your full code?