MadLibs Java Project Issues

When I complete this mad libs project about a story, I am unsure what I am doing wrong as I thought I debugged everything. There seems to be a lot of errors, and I followed the directions correctly.

The code:
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;

After naming and initializing the strings, the code seems to be wrong:

String name1 = “Bobby”;

  String name2 = "Jake";

  String adjective1 = "happy";

  String adjective2 = "exciting";

  String adjective3 = "upset";

  String verb1 = "chant";

  String noun1 = "farmers";

  String noun2 = "Milk";

  String noun3 = "We want milk back";

  String noun4 = "townspeople";

  String noun5 = "toxic sludge";

  String noun6 = "Cows";

  int number = 2120;

  String place1 = "Planet Anamorphis";

  

  System.out.println(story);

I would be grateful for any help. Thank you!

Hello @arc7697720166, welcome to the forums! What exactly isn’t working here? Can you post any error messages you get or unexpected outcomes, please?

Thank you for your reply. This are all the errors to the code above:

MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable name1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable adjective1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable adjective2
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable noun1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable noun2
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable verb1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable noun3
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable noun4
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable adjective3
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable name1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable name2
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable name1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable place1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable name1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable noun5
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable name1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable number
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String story = "This morning “+name1+” woke up feeling “+adjective1+”. ‘It is going to be a “+adjective2+” day!’ Outside, a bunch of "+noun1+"s were protesting to keep “+noun2+” in stores. They began to “+verb1+” to the rhythm of the “+noun3+”, which made all the "+noun4+"s very “+adjective3+”. Concerned, “+name1+” texted “+name2+”, who flew “+name1+” to “+place1+” and dropped “+name1+” in a puddle of frozen “+noun5+”. “+name1+” woke up in the year “+number+”, in a world where "+noun6+“s ruled the world.”;
^
symbol: variable noun6
location: class MadLibs
18 errors

Just curious, can you post your full code and format it correctly, please? There’s always a chance these errors are coming from the fact that I can’t see a class declaration, etc, but it most likely is something else…

I had the same problem, but I fixed it by putting the declared variables, before the String story variable just below the public static void name (String args). I don’t know what is that called, lol.

  String name1 = "  ";

  String adjective1 = "  ";

  String adjective2 = "  ";

  String adjective3 = "  ";

  String verb1 = "  ";

  String noun1 = "  ";

  String noun2 = "  ";

  String noun3 = "  ";

  String noun4 = "  ";

  String noun5 = "  ";

  String noun6 = "  ";

  String name2 = "  ";

  int number =  ;

  String place1 = "  ";
1 Like

This worked! Thank you so much for the solution!

1 Like

I had the same issue and this solved it. Thanks!

1 Like

Thanks! This worked.

1 Like

Same problem here. Thanks for the solution.

1 Like

While the solution has already been posted, I just want to point out that you generally wouldn’t define the story variable that way in real life because of the exact problem you ran into here. A simple way of bypassing the problem would be to declare the story variable without initializing it. Then make a function that either sets that string to the story variable or returns the string so you can set it manually in the main(). Or do it in a constructor.

String story;

void createStory() {
        this.story = "This morning "+name1+" woke up feeling "+adjective1+". ‘It is going to be a "+adjective2+" day!’ Outside, a bunch of "+noun1+"s were protesting to keep "+noun2+" in stores. They began to "+verb1+" to the rhythm of the "+noun3+", which made all the "+noun4+"s very "+adjective3+". Concerned, "+name1+" texted "+name2+", who flew "+name1+" to "+place1+" and dropped "+name1+" in a puddle of frozen "+noun5+". "+name1+" woke up in the year "+number+", in a world where "+noun6+"s ruled the world.";
    }

Or with a constructor. I generated this in about 2 seconds with IntelliJ’s auto generate tool.

public MadLib(String name1, String name2, String adjective1, String adjective2, String adjective3, String verb1, String noun1, String noun2, String noun3, String noun4, String noun5, String noun6, int number, String place1) {
        this.name1 = name1;
        this.name2 = name2;
        this.adjective1 = adjective1;
        this.adjective2 = adjective2;
        this.adjective3 = adjective3;
        this.verb1 = verb1;
        this.noun1 = noun1;
        this.noun2 = noun2;
        this.noun3 = noun3;
        this.noun4 = noun4;
        this.noun5 = noun5;
        this.noun6 = noun6;
        this.number = number;
        this.place1 = place1;
    }
1 Like