hoq do i get this program to type in a string at the end of

hoq do i get this program to type in a string at the end of the sentences (

Change the previous program so the user may input the word to end the phrase. The string holding the user’s input word will be passed to the proverb function instead of passing a number to it. Notice that this change requires you to change the proverb function heading and the prototype as well as the call to the function.)

#include <iostream>
#include <string>
using namespace std;
// Fill in the prototype of the function writeProverb.
void writeProverb(string wordCode);
int main()
{
   string wordCode;
   cout << \"Given the phrase:\" << endl;
   cout << \"Now is the time for all good men to come to the aid of their ___\" << endl;
   cout << \"Input party if you want the sentence to be finished with party\" << endl;
   cout << \"Input country if you want the sentence to be finished with country\" << endl;
   cout << \"Please input your choice now\" << endl;
   cin >> wordCode;
   writeProverb(wordCode);
   return 0;
}
//    ***********************************************************************
//    writeProverb
//   
//    task:        This function prints a proverb. The function takes a number
//                from the call. If that number is a 1 it prints \"Now is the time
//                for all good men to come to the aid of their party.\"
//                If that number is 2 it prints \"Now is the time for all good men
//                to come to the aid of their country.\"
//    data in:    code for ending word of proverb (integer)
//    data out:   no actual parameter altered
//
// **************************************************************************
void writeProverb(string wordCode)
  
   // Fill in the body of the function to accomplish what is described above

       {

           cout << \"Now is the time for all good men to come to the aid of their \";
          

       }
  

Solution

// This program will allow you type in strings at the end of the sentences

code to copy:

#include <iostream>

#include <string>

using namespace std;

void writeProverb(string);

int main ()

{

       

        string lastWord;

        cout << \"Given the phrase:\" << endl;

        cout << \"Now is the time for all good men to come to the aid of their ___\" << endl;

        cout << \"Input the word you would like to have finish that proverb\" << endl;

    cout << \"Please input your choice now\" << endl;

        cin >> lastWord;

        cout << endl;

        writeProverb(lastWord);

       

        return 0;

}

// ******************************************************************************

//                          

//  

//   task:      This function prints a proverb. The function receives a word

//              from the call and prints that word as the last word of the

//              proverb

// data in:   word for ending the proverb

//   data out: none

//

//   *****************************************************************************

void writeProverb (string word)

{

        cout << \"Now is the time for all good men to come to the aid of their \" << word << endl;

}

hoq do i get this program to type in a string at the end of the sentences ( Change the previous program so the user may input the word to end the phrase. The st
hoq do i get this program to type in a string at the end of the sentences ( Change the previous program so the user may input the word to end the phrase. The st

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site