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 trialAaron Lynch
529 PointsParsing error?
So i came across this parsing error while running my code:
TreeStory.java:26: error: reached end of file while parsing
String adverb = console.readLine("Enter an adverb: ") ; }}
^
1 error
I looked it up and found that it has something to do with closing the brackets. But I can't seem to find my error. Any help is greatly appreciated
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: ");
if (noun.equals("dork")) {console.printf("That language is not allowed. Exiting.");
String adjective = console.readLine("Enter an adjective: ");
String noun = console.readLine ("Enter a noun: ");
String adverb = console.readLine("Enter an adverb: ") ; }}
1 Answer
Dee Dee Berry
2,605 PointsHi Aaron!
You are missing the closing curly brace for your second if statement and you also have some of your lines of code mixed up. Your second if statement should begin after
String noun = console.readLine("Enter a noun: ");
Hope this helps! :-)
Aaron Lynch
529 PointsAaron Lynch
529 PointsThank you! it does!