troubleshooting Question

Another C++ Programming Assignment Gone Wrong...More Pig Latin

Avatar of AlexisRyan
AlexisRyan asked on
Visual C++.NET
6 Comments1 Solution899 ViewsLast Modified:
I read the other pig latin one that is on the site but this one is a little different. Can anyone tell me where I'm going horribly wrong? Four days of trying and I'm utterly lost.
//-------------------------------------------------
//Programming Assignment: LAB5B
//Developer:              Alexis Stephens
//Date Written:           9-29-10
//Purpose:                Video Game Player Program
//-------------------------------------------------


#include <iostream>
#include <string>

using namespace std;

void pigLatingString(string line);
bool find(char x);
void substr(string changed);
void nonVowel(char begin, string end);

int main()
{
      char ch;
      string word;
      string start;
      string line;
      
      //Display the heading
      cout << "*** You will be prompted to enter a string of  ***" <<
      "*** words. The string will be converted into   ***" <<
      "*** Pig Latin and the results displayed.       ***" <<
      "*** Enter as many strings as you would like.   ***" << endl;

    //While the condition is true
      while (line.length()!= 0)
      {
            cout << "Enter a group of words or ENTER to quit: " << endl;
            getline(cin,line);
            pigLatinString(line);
      }
      return 0;
}

void pigLatinString(string line)
{
   //Declare and initialize string variables len, counter, start, begin, word and newString
      string word;
      string start;
      char ch;
      int len = line.find(' ');
      string begin(word,1);
      string newString;

   //While condition is true
      while (line.length() !=0)
      {
            int len = line.find(' ');
            if(len >0)
            {
                  word = line.substr(0,len);
                  start= word.substr(0,1);
                  ch = start[0];
                  string begin(word,1);
            }
            if (find (ch))
            {
                  substr(word);
            }
            else
            {
                  nonVowel(ch,begin);
            }
            line = line.substr(len+1);else
            {
            word = line;
            ch = line[0];
            string begin(word,1);
            if (find (ch))
            {
                  substr(word);
            }
            else
            {
                  nonVowel(ch, begin);
                  line= "";
            }
}

bool find(char x)
{
      char low_case = tolower (x);
      
      if (low_case == 'a')
            return true;
      else if (low_case == 'e')
            return true;
      else if (low_case== 'i')
            return true;
      else if (low_case == 'o')
            return true;
      else if (low_case == 'u')
            return true;
      else
            return false;

}
void substr(string changed)
{
      string newString;
      newString = changed+"way";
      cout << newString << " ";
}
void nonVowel(char begin, string end)
{
      string newString;
      newString = end+begin+"ay";
      cout << newString <<" ";
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros