Pig latin Translator program. stuck... stub program?

The program is supposed to basically ask the user for a choice from a menu to translate an entire .txt file or translate a single sentence to pig latin.

Words that start with a vowel (A, E, I, O, U) simply have "way" appended to the end of the word.
Words that start with a consonant have all consonant letters up to the first vowel moved to the end of the word (as opposed to
just the first consonant letter), and then "AY" is appended. ('y' is considered as a vowel in this context)
Ensure punctuation is preserved, i.e., periods and commas should appear after translated words in the same places
Correctly translate "qu" (e.g., ietquay instead of uietqay) which means “qu” always stays together
Differentiate between "y" as vowel and "y" as consonant (e.g. yellow = ellowyay and style = ylestay)


The structure chart given to me looks like:
                  main
            -------------------
     getMenuOption       translateLine()
                       --------------------
                  getNextWord()        translateWord()
                                  ----------------------------------------
                              isPunctuation()      isVowel()        splitWord()




The program must contain funtion prototypes, function calls and funtion headers.
The main funtion should declare variables needed and only contain function call to getMenuOption and translateLine.

Function Prototypes given to me are:

string getMenuOption(); // display menu and validate user input, return chosen option

string translateLine(string); // process line one word at a time, building up the translated line

string translateWord(string); // translate given word and return translated word

string getNextWord(string, int); // pick off characters making up a word starting with given position

bool isVowel(char); // answers the question “is given character a vowel?

bool isPunctuation(char); // answers the question “is given character punctuation?”

void splitWord(string, int, string &, string &); // split given word starting at position given
// i.e., “hello” with position


Here is what I have so far. This is my very first c++ course I think this is rediculous for a begginer class. I'm lost so any help or guidance would be appreciated.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <iomanip>
using namespace std;

void showMenu();


int main()
{
	string pigsentence, sentence, choice;          // hold menu choice
	string translateLine();

	do
	{
		choice = showMenu();
		if (choice == "1")
		{                                                //read data from file





		}
		else											//process a single sentence
		{
			getline(cin, sentence);
			pigsentence = translateLine(sentence);
			cout << pigsentence;
		}
	}
}

string showMenu()
{ 
	string choice;

	cout << "Menu:" << endl;
	cout << "===================================================" << endl;
	cout << "[1] to process a file" << endl;
	cout << "[2] to process a single sentence" << endl;
	getline(cin, choice);

	return choice;
}

string translateLine()
{
Last edited on
You wouldn't happen to be a student at BG taking CS 2010, would you? if so, then I may be able to help as I am struggling also, and we could potentially meet tomorrow if you still need help.
Topic archived. No new replies allowed.