Here is an outline of the NameGame2.c Program


/*Program to play the name game, and verify user input */

#include <iostream.h>
#include <string>

void main(){
  //here we will declare some variables
  string name, root, indexchar;
  int i;
  int NameLength, FirstVowel;

  //Now we begin the action
  do{
  /*Your job is to put the red lines below inside of
      a while loop, so that as long as the user
      enters "illegal" names, the program will keep
      looping, asking the user for another input.   */
    //First we output a line to the user
    cout << "Enter a name: ";
    //Now we get the user's response
    cin >> name;

    //We compute the length of the input name
    NameLength = name.length();

    //Now we use a loop to find the first vowel
    for(i = 0; i < NameLength; i++){
      indexchar = name.substr(i,1);
      if(indexchar == "a" || indexchar == "e" || indexchar == "i"
         || indexchar == "o" || indexchar == "u"){
        FirstVowel = i;
        break;                //"break" exits the loop it is in
      }
    }

    //Now that we know where the first vowel is, we can
    //select the substring that starts there
    root = name.substr(FirstVowel, NameLength - FirstVowel);

    //We have all the info we need, so we proceed to output
    cout << "\n" << name << ", " << name << ", Bo B" << root << endl;
    cout << "Banana, Fana, Fo F" << root << endl;
    cout << "Fe, Fi, Mo M" << root << endl;
    cout << name << "!" << endl;

  }while(name != "Done" && name != "done");  //This matches the "do" at the top
}