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 trialVeronica Littlefield
769 PointsLopping until the Value passes - problems with the do and while...
Tried to duplicate what was done in the lesson but I keep getting an error. What am I doing wrong?? This is SO frustrating!
public class TreeStory { public static void main (String [] args) { Console console = System.console (); 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”); } String name = console.readLine (“Enter a name: “); String adjective = console.readLine (“Enter an adjective: “); String noun; boolean isInvalidWord; do { noun = console.readLine (“Enter a noun: “); isInvalidWord = (noun.equalsIgnoreCase(“dork”) | | noun.equalsIgnoreCase(“jerk”) ); if (isInvalidWord) { console.printf(“That language is not allowed. Try again. \n\n”); } } while (isInvalidWord);
String adverb = console.readLine (“Enter an adverb: “);
String verb = console.readLine (“Enter a verb ending in -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);
error code I keep getting on the above
TreeStory.java:30: error: reached end of file while parsing
console.printf("He is always %s %s.\n", adverb, verb);
^
1 error
// I have initialized a java.io.Console for you. It is in a variable named console.
2 Answers
Daniel Heyde
3,352 PointsIt looks like it is reaching the end of the file before it expects the end. This happens when it hits the last line and there are still open brackets. Try adding two brackets }} to the end to close the class and the main function.
Veronica Littlefield
769 PointsYa, I realized once I copied the code. I also have to revisit it again after reviewing the Feeling Loopy segments. I shall persevere!
Veronica Littlefield
769 Pointsfigured it ou!
Chris Jones
Java Web Development Techdegree Graduate 23,933 PointsChris Jones
Java Web Development Techdegree Graduate 23,933 PointsHey Veronica, hang in there:)!
Could you edit your question and reformat your code per the Markdown Cheatsheet? It's hard to tell what the problem is when the code is displayed as it is. You can add ``` a line above where your code starts and a line below where your code ends in order to format your code.