C++ PROGRAMING Write a program which generates interactive stories. Your program
ID: 663362 • Letter: C
Question
C++ PROGRAMING
Write a program which generates interactive stories. Your program should begin by asking the user a number of questions such as : What is your name? How old are you? What is your favorite color? Etc. After obtaining a sufficient amount of personal information, your program should output a short story (at least one paragraph) which incorporates user's personal information you have obtained via questioning. (The topic of the story is up to you, but please keep it clean) The generated story should be somewhat diferent every time the program is run (randomly generate alternative endings), randomly select different descriptions of objects (blue car, green car, red car), etc.
Your program should make use of pointers and arrays to deal with strings.
SAMPLE OUTPUT:
What is your name? Jack
How old are you? 26
What is your favorite color? red
Jack is a 26 year old who likes his red car...
SAMPLE OUTPUT(second run of the same program):
What is your name? Jack
How old are you? 26
What is your favorite color? red
Jack is a 26 year old who likes his red Nissan Altima...
Explanation / Answer
int main()
{
string name,profession,hobby,color;
int age;
cout<<"What is your name?";
cin>>name;
cout<<"How old are you?";
cin>>age;
cout<<"What is your profession?";
cin>>profession;
cout<<"What are your hobbies?";
cin>>hobby;
cout<<"What is your favourite color?";
cin>>color;
cout<<name<<" is "<<age<<" old "<<"working as "<<profession<<" and likes to do "<<hobby<<"."<<name<<" likes "<color<<" color.";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.