CIS 180: Word Game (JAVA) Write a program that plays a word game with the user.
ID: 3673021 • Letter: C
Question
CIS 180: Word Game (JAVA) Write a program that plays a word game with the user. The program should ask the user to enter the following: - Their name - Their age - The name of a city - The name of a college - A profession - A type of animal - A pet’s nameAfter the user has entered these items, the program should display the following story, inserting the user’s input into the appropriate locations:
There once was a person named NAME who lived in CITY. At the age of AGE, NAME went to college at COLLEGE. NAME graduated and went to work as a PROFESSION. Then, NAME adopted a(n) ANIMAL named PETNAME. They both lived happily ever after!
Write a second story of your choosing incorporating all 7 inputs from the user. Have this display after the first story, so that now the program tells two stories. - Comments are worth 7 points and following conventions is worth 5 points. CIS 180: Word Game (JAVA) Write a program that plays a word game with the user. The program should ask the user to enter the following: - Their name - Their age - The name of a city - The name of a college - A profession - A type of animal - A pet’s name
After the user has entered these items, the program should display the following story, inserting the user’s input into the appropriate locations:
There once was a person named NAME who lived in CITY. At the age of AGE, NAME went to college at COLLEGE. NAME graduated and went to work as a PROFESSION. Then, NAME adopted a(n) ANIMAL named PETNAME. They both lived happily ever after!
Write a second story of your choosing incorporating all 7 inputs from the user. Have this display after the first story, so that now the program tells two stories. - Comments are worth 7 points and following conventions is worth 5 points.
Explanation / Answer
using namespace std;
int main()
{
string userName;
string userCity;
int userAge;
string userCollege;
string userProfession;
string userAnimal;
string userPetName;
cout << "Enter name: ";
getline(cin,userName);
cout << "Enter city: ";
getline(cin,userCity);
cout << "Enter age: ";
cin >> userAge;
cout << "Enter college: ";
cin.ignore(100,' ');
getline(cin,userCollege);
cout << "Enter profession: ";
getline(cin,userProfession);
cout << "Enter animal: ";
getline(cin,userAnimal);
cout << "Enter pet name: ";
getline(cin,userPetName);
cout<< " ";
cout << " There once was a person named " << userName << " who lived in " << userCity << ". ";
cout << "At the age of " << userAge;
cout << ", " << userName << " went to college at " << userCollege<< ". ";
cout <<userName << " graduated and went to work as a " << userProfession <<". "<<"Then, ";
cout << userName << " adopted a(n) " << userAnimal << " named " << userPetName << ". ";
cout << "They both lived happily ever after! " <<" ";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.