Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Write a program that plays the game of Mad Libs. 2.Your program must prompt th

ID: 3624242 • Letter: 1

Question

1.Write a program that plays the game of Mad Libs.
2.Your program must prompt the user to enter the following information as strings in this order:

a. Your first name

b. Your instructor's last name

c. A food

d. A number between 100 and 120

e. An adjective

f. A color

g. An animal

3. After the strings are entered, substitute the strings into the following story and output the story to the console:

Dear Instructor [Instructor Name]

I am sorry that I am unable to turn in my homework today. First I ate a rotten [food], which made me turn [color] and extremely ill. I came down with a fever of [number]. Next, my [adjective] pet [animal] must have smelled the remains of the [food] on my homework, because my pet ate my homework.

I knew I should not have ordered that [animal] on eBay!

I know you do not accept late homework but I am hoping you will make an exception in my case.

Sincerely, [Your name]

Explanation / Answer

please rate - thanks

hope it's okay that the story is in a file

#include <iostream>
#include <fstream>
using namespace std;
int main()
{string name,instructor,food,number,adjective,color,animal;
string word,prompt;
char space;
ifstream in;
int n;
cout<<"Enter Your first name: ";
cin>>name;
cout<<"Enter Your instructor's last name: ";
cin>>instructor;
cout<<"Enter a food: ";
cin>>food;
cout<<"Enter anumber between 100 and 120: ";
cin>>number;
cout<<"Enter an adjective: ";
cin>>adjective;
cout<<"Enter a color: ";
cin>>color;
cout<<"Enter an animal: ";
cin>>animal;
in.open("input.txt");       
if(in.fail())           
   { cout<<"story file did not open please check it ";
   system("pause");
   return 1;
   }
in>>word;
while(in)
{if(word[0]=='[')
      {n=word.find(']',0);
       if(n<word.length())
            prompt=word.substr(1,n-1);
       else
           {prompt=word.substr(1,word.length())+" ";
           in>>word;
           prompt=prompt+word.substr(0,word.length()-1);
           }
       if(prompt.compare("Instructor Name")==0)
              cout<<instructor;
       else if(prompt.compare("food")==0)
              cout<<food;
        else if(prompt.compare("color")==0)
              cout<<color;     
        else if(prompt.compare("adjective")==0)
              cout<<adjective;
       else if(prompt.compare("animal")==0)
              cout<<animal;
        else if(prompt.compare("Your name")==0)
              cout<<name;
        else if(prompt.compare("number")==0)
              cout<<number;                  


      }

else
      cout<<word;
in.get(space);
cout<<space;
in>>word;
}
cout<<endl;
system("pause");
return 0;
}
   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote