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
johnacosta
275 PointsI am having a really hard time getting passed these errors...
This is the error i keep getting... TreeStory.java:28 error: illegal start of expression String verb = console.readLine("Enter a verb ending in - ing: ");
TreeStory.java:36 error: reached and of file while parsing } 19 errors
I can't move forward until i get passed this...
7 Answers
Mihai Craciun
13,520 PointsI changed all the quotation marks and it compiled just fine for me. I will let your code below for you to copy it:
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__os a __ adjective__ __ noun__. They are always __ adverb__ __ verb__.
String name = console.readLine("Enter a name: ");
String adjective = console.readLine("Enter an adjective : ");
String noun = console.readLine("Enter a noun: ");
if(noun.equals("dork")){
console.printf("That language is not allowed. Exiting.\n\n");
System.exit(0);
String adverb = console.readLine("Enter a 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);
}
}
}
A Y
1,761 PointsJohn,
I am not sure 100% what are the bugs without seing the codes but these may help you:
1) Make sure you have declared the console "Console console = System.console();" before declaring the "String verb = console.readLine("Enter a verb ending in - ing: ");" that may fix the first bug.
2) Make sure you have not missed any closing braces "}" to fix the second bug. "TreeStory.java:36 error: reached and of file while parsing } 19 errors".
3) Make sure you have not missed any ";" semicolon after any statement.
Hope this may help you, Amir
johnacosta
275 Pointsi am not sure how to import the code on this. Do you know how?
Mihai Craciun
13,520 Pointsjust copy it and paste it here: You can use the Markdown Cheatsheet for syntax examples to make it look like a normal code
johnacosta
275 Pointsimport 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__os a __ adjective__ __ noun__. They are always __ adverb__ __ verb__.
String name = console.readLine("Enter a name: ");
String adjective = console.readLine(“Enter an adjective : ”);
String noun = console.readLine(“Enter a noun: ”);
if(noun.equals("dork")){
console.printf("That language is not allowed. Exiting.\n\n");
System.exit(0);
String adverb = console.readLine(“Enter a 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);
}
}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__os a __ adjective__ __ noun__. They are always __ adverb__ __ verb__.
String name = console.readLine("Enter a name: ");
String adjective = console.readLine(“Enter an adjective : ”);
String noun = console.readLine(“Enter a noun: ”);
if(noun.equals("dork")){
console.printf("That language is not allowed. Exiting.\n\n");
System.exit(0);
String adverb = console.readLine(“Enter a 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);
}
}
Mihai Craciun
13,520 PointsI've found your problem. You have used a wrong type of quotation symbols. I think this is mostly because you have the keyboard input method selected for another language. Try to set up your keyboard language in English the check if the problem is solved. If you don't know how to change it please tell me your Operating System so i can guild you.
If you look closely below you will see the difference between my quotation symbols and yours
//Your code
String adjective = console.readLine(“Enter an adjective : ”);
// ^look here ^and here
//How it should look like
String adjective = console.readLine("Enter an adjective : ");
// ^look here ^and here
johnacosta
275 PointsThe problem is that I tried to change it and it is still the same. Could it be the workspace or is it me?
johnacosta
275 PointsThank you so much! I am going to try to fix it!
Mihai Craciun
13,520 PointsMihai Craciun
13,520 Pointscan i see the whole code? It would be easier to track the error