Question #45587
"Write a program that plays a word game with the user. The program should ask the user to enter the following:

His/her Name

His/her Age

Name of a City

Name of a College

A Profession

A Type of Animal

A Pet's Name

After the user has entered these items, the program shoulld 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 every after!
1
Expert's answer
2014-09-02T05:23:38-0400
#include <iostream>#include <string>int main() {    std::string name, age, city, college, profession, animal, petsName;    std::cout << "Please input your name." << std::endl;    std::getline(std::cin, name);    std::cout << "Please input your age." << std::endl;    std::getline(std::cin, age);    std::cout << "Please input the city you're from." << std::endl;    std::getline(std::cin, city);    std::cout << "Please input the name of college you graduated." << std::endl;    std::getline(std::cin, college);    std::cout << "Please input your profession." << std::endl;    std::getline(std::cin, profession);    std::cout << "Please input the type of animal you have or want to have." << std::endl;    std::getline(std::cin, animal);    std::cout << "Please input your pet's name." << std::endl;    std::getline(std::cin, petsName);    std::cout << "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 " << petsName << ". They both lived happily every after!" << std::endl;    return 0;}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS