Problem 1 the story generator... answer in c++ only please!!! I\'m trying to che
ID: 3886671 • Letter: P
Question
Problem 1 the story generator... answer in c++ only please!!! I'm trying to check my answers.
Problem 1: The Story Generator In the game Mad-libs, players are asked for parts of speech, such as noun, adjective, or adverb, and those words are plugged into a template sentence to generate a sometimes- funny story Menu Function Write a function called menu that is called by main when your program starts. Inside your menu function, you should first ask the user which story they want to play. Your question should look like: "Which story would you like to play? Enter the number of the story (1, 2, or 3) or type to quit: " If the user types q your program should print "good bye" and exit the function. If the user types in an invalid input, for example "17" or "slkerjqoe", you should print "Valid choice not selected." If the user types in a valid story number, the menu function should call the corresponding story function (story1, story2, or story3) The user should be allowed to play the game as many times as they like. After printing the new story, your program should ask again which story they would like to play "Which story would you like to play? Enter the number of the story (1, 2, or 3) or type q to quit: "Explanation / Answer
#include<iostream>
using namespace std;
void story1(void){
char noun[100],occ[100],ani[100],place[100];
cout<<"Enter a plural noun: "; cin>>noun;
cout<<"Enter an occupation: "; cin>>occ;
cout<<"Enter an animal name: "; cin>>ani;
cout<<"Enter a place: "; cin>>place;
cout<<"In the book War of the "<<noun<<", the main character is an"<<endl;
cout<<"anonymous "<<occ<<" who records the arrival of the "<<ani<<"s in "<<place<<"."<<endl;
}
void story2(void){
char na[100],stc[100];
cout<<"Enter a name: "; cin>>na;
cout<<"ENter a state/country: "; cin>>stc;
cout<<na<<" I've got a feeling we're not in "<<stc<<" anymore."<<endl;
}
void story3(void){
char fn[100],re[100],verb[100];
cout<<"Enter a first name: "; cin>>fn;
cout<<"Enter a relative: "; cin>>re;
cout<<"Enter a verb: "; cin>>verb;
cout<<"HEllo. My name is "<<fn<<". You Killed my "<<re<<"."<<endl;
cout<<"Prepare to "<<verb<<"."<<endl;
}
void menu(){
jump:
char c;
cout<<"Which story would you like to play? "<<endl;
cout<<"Enter the number of the story(1, 2, or 3) or type q to quit: "<<endl;
char n;
cin>>n;
switch(n){
case '1':
story1();
cout<<"Do you want to play again(y/n)"<<endl;
cin>>c;
if(c=='y'){
goto jump;
}
break;
case '2':
story2();
cout<<"Do you want to play again(y/n)"<<endl;
cin>>c;
if(c=='y'){
goto jump;
}
break;
case '3':
story3();
cout<<"Do you want to play again(y/n)"<<endl;
cin>>c;
if(c=='y'){
goto jump;
}
break;
case 'q':
cout<<"good bye"<<endl;
break;
default:
cout<<"Valid choice not selected."<<endl;
cout<<"Do you want to play again(y/n)"<<endl;
cin>>c;
if(c=='y'){
goto jump;
}
break;
}
}
int main(){
menu();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.