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 trialRobert Roberson
Courses Plus Student 8,401 PointsFor some reason I can't get the "or" command to work, the pipelines always show up as being incorrect syntax. What now?
So, when I take that or statement out it works and when I try to put it back in I get an error in syntax. I have already posted a similar message but no one seems to be able to help me. Please tell me that i have not wasted my $49.
5 Answers
Robert Roberson
Courses Plus Student 8,401 Pointspublic 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, you must be at least 13 to use this program. \n"); System.exit(0); } String name = console.readLine("Enter your name: "); String adjective = console.readLine("Enter an adjective: "); String noun =console.readLine("Enter a noun: "); if (noun.equalsIgnoreCase("dork")) || noun.equalsIgnoreCase("jerk")) { console.printf("The language is not allowed. Exiting! \n\n"); System.exit(0); } String gerund = console.readLine("Enter a gerund: "); String adverb = console.readLine("Enter an averb: "); }
Allan Clark
10,810 PointsLooks like you might have too many close parens in your if statement.
if (noun.equalsIgnoreCase("dork")) ||
noun.equalsIgnoreCase("jerk"))
So after "dork" the first close paren closes the equalsIgnoreCase() method call, the second close paren closes the condition for the if statement. That causes the || to be outside the conditional statement so the compiler doesn't know what to do with it. Delete that second paren and you should be good.
Side Note: if you have the error narrowed down to one line just post that line instead of the full class. Will help us respond quicker.
As for the forum question, students and teachers are able to answer and post questions in the forum. For the most part it is left to the students though because nothing solidifies a concept like answering someone else's questions about it.
Also I for sure don't think you wasted your money, TreeHouse is an amazing resource for anyone trying to learn software development. Try taking a class online at a University and you will pay $150+ per month to watch 2 hour long lecture videos and no guided interactive practice, just huge programming projects.
Grigorij Schleifer
10,365 PointsHey Roger, could you post your code please?
Do you use || command?
And i dont think at all, that you wasted your money. Treehouse is awesome .....
Robert Roberson
Courses Plus Student 8,401 PointsI used || which shows as an error.
Robert Roberson
Courses Plus Student 8,401 Pointspublic 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, you must be at least 13 to use this program. \n"); System.exit(0); } String name = console.readLine("Enter your name: "); String adjective = console.readLine("Enter an adjective: "); String noun =console.readLine("Enter a noun: "); if (noun.equalsIgnoreCase("dork")) || noun.equalsIgnoreCase("jerk")) { console.printf("The language is not allowed. Exiting! \n\n"); System.exit(0); } String gerund = console.readLine("Enter a gerund: "); String adverb = console.readLine("Enter an averb: "); }
Robert Roberson
Courses Plus Student 8,401 PointsYou can see it better here. small question does anyone from treehouse answer these question or just students?