Need Help with Java Variables: Mad Libs!

Hi guys, my question is why i get this errors???

public class MadLibs {
/*
This program generates a mad libbed story.
Author: Khoa
Date: 11/25/2019
*/
public static void main(String args){
String +name1+= “Venesa”;
String +adjective1+= “great”;
String +adjective2+= “wonderful”;
String +adjective3+= “excited”;
String +verb1+= “shout”;
String +nouns1+= “Hipster”;
String +nouns2+= “greens”;
String +nouns3+= “chant”;
String +nouns4+= “companie”;
String +nouns5+= “water”;
String +nouns6+= “”;
String +name2+= “Khoa”;
Int +number+= 2049;
String +place1+= “Los Angeles”;
System.out.println(story);

  //The template for the story
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.";
}       

}

MadLibs.java:8: error: cannot find symbol
String +name1+= “Venesa”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:8: error: cannot find symbol
String +name1+= “Venesa”;
^
symbol: variable name1
location: class MadLibs
MadLibs.java:9: error: cannot find symbol
String +adjective1+= “great”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:9: error: cannot find symbol
String +adjective1+= “great”;
^
symbol: variable adjective1
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String +adjective2+= “wonderful”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:10: error: cannot find symbol
String +adjective2+= “wonderful”;
^
symbol: variable adjective2
location: class MadLibs
MadLibs.java:11: error: cannot find symbol
String +adjective3+= “excited”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:11: error: cannot find symbol
String +adjective3+= “excited”;
^
symbol: variable adjective3
location: class MadLibs
MadLibs.java:12: error: cannot find symbol
String +verb1+= “shout”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:12: error: cannot find symbol
String +verb1+= “shout”;
^
symbol: variable verb1
location: class MadLibs
MadLibs.java:13: error: cannot find symbol
String +nouns1+= “Hipster”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:13: error: cannot find symbol
String +nouns1+= “Hipster”;
^
symbol: variable nouns1
location: class MadLibs
MadLibs.java:14: error: cannot find symbol
String +nouns2+= “greens”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:14: error: cannot find symbol
String +nouns2+= “greens”;
^
symbol: variable nouns2
location: class MadLibs
MadLibs.java:15: error: cannot find symbol
String +nouns3+= “chant”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:15: error: cannot find symbol
String +nouns3+= “chant”;
^
symbol: variable nouns3
location: class MadLibs
MadLibs.java:16: error: cannot find symbol
String +nouns4+= “companie”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:16: error: cannot find symbol
String +nouns4+= “companie”;
^
symbol: variable nouns4
location: class MadLibs
MadLibs.java:17: error: cannot find symbol
String +nouns5+= “water”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:17: error: cannot find symbol
String +nouns5+= “water”;
^
symbol: variable nouns5
location: class MadLibs
MadLibs.java:18: error: cannot find symbol
String +nouns6+= “”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:18: error: cannot find symbol
String +nouns6+= “”;
^
symbol: variable nouns6
location: class MadLibs
MadLibs.java:19: error: cannot find symbol
String +name2+= “Khoa”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:19: error: cannot find symbol
String +name2+= “Khoa”;
^
symbol: variable name2
location: class MadLibs
MadLibs.java:20: error: cannot find symbol
Int +number+= 2049;
^
symbol: variable Int
location: class MadLibs
MadLibs.java:20: error: cannot find symbol
Int +number+= 2049;
^
symbol: variable number
location: class MadLibs
MadLibs.java:21: error: cannot find symbol
String +place1+= “Los Angeles”;
^
symbol: variable String
location: class MadLibs
MadLibs.java:21: error: cannot find symbol
String +place1+= “Los Angeles”;
^
symbol: variable place1
location: class MadLibs
MadLibs.java:22: error: cannot find symbol
System.out.println(story);
^
symbol: variable story
location: class MadLibs
MadLibs.java:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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:41: 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
47 errors

Hi @java6487564020 - welcome to the forums.

From the docs:

  • Variable names are case-sensitive. A variable’s name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign " $ ", or the underscore character " _ ". The convention, however, is to always begin your variable names with a letter, not " $ " or " _ ". Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it’s technically legal to begin your variable’s name with " _ ", this practice is discouraged. White space is not permitted.
  • Subsequent characters may be letters, digits, dollar signs, or underscore characters. Conventions (and common sense) apply to this rule as well. When choosing a name for your variables, use full words instead of cryptic abbreviations. Doing so will make your code easier to read and understand. In many cases it will also make your code self-documenting; fields named cadence , speed , and gear , for example, are much more intuitive than abbreviated versions, such as s , c , and g . Also keep in mind that the name you choose must not be a keyword or reserved word.

All your variable names are like this: +name1+. These are not valid variable names, and would be the first thing I would suggest you fix. :slight_smile:

1 Like

thanks a lot ! just found out i just spelled nouns instead of noun haha. But thanks for the help!