Hi, I would like help on the following program. I do not know where to start so
ID: 3619469 • Letter: H
Question
Hi, I would like help on the following program. I do not know where to start so anything would be helpful. This is supposed to be a C program by the way.Write a program the "speaks" pig-latin. Words in pig-latin are taken from English. To form a word in pig-latin, the first letter of the English word beginning with a consonant is removed and added at the end of the word, adding the letters ay after the moved consonant. Words that begin with a vowel are simply appended with ay. Thus, in pig-latin, pig-latin is igpay-atinlay.
Your program will read a sentence at a time using fgets. It is to parse the words into strings. As words are parsed, they are to be converted to pig-latin and printed.
I would really appreciate any help I recieve on this problem. Thank You.
Explanation / Answer
#include
#include
using
// These functions explained below
void
void
void
void
void
void
void
int
{
string first_name, last_name;
{
input(first_name, last_name);
converting_to_lower_case_letters(first_name, last_name);
changing_to_pig_latin(first_name, last_name);
pig_latin_name(first_name, last_name);
cout <<
cin >> response;
cout << endl;
}
}
// This void function is for 2 statement spaces between sentences
void
{
cout << endl << endl;
}
// This void function explains what the program is about to perform
void
{
cout <<
spaces();
}
/* This void function is for entering the users 2 strings variables(their first and last name),
I used the ampersand to change the string variables and to refer back to their changed values */
void
{
cout <<
cin >> first_name;
cout <<
cin >> last_name;
}
/* This void function is for converting the users first and last name to all lowercase letters,
the first for statement goes through the length of the users first name and changes it to lower case,
*/
void
{
{
first_name[i] = tolower(first_name[i]);
}
{
last_name[i] = tolower(last_name[i]);
}
}
/* This void is for swapping two integer values with each other,
created a temporary variable to hold the value of one of the variables,
then set the temporary to the first value of the integer used,
then set the first number equal to the second number,
then the second number with the value of the temporary
variable which is the first variable */
void
{
string temporary;
temporary = number_1;
number_1 = number_2;
number_2 = temporary;
}
void
{
first_name_letter = first_name[0];
last_name_letter = last_name[0];
{
{
first_name_count++;
swap(first_name[i], first_name[i+1]);
}
first_name[first_name_count - 1] = first_name_letter;
first_name = first_name +
}
{
first_name = first_name +
}
{
{
last_name_count++;
swap(last_name[i], last_name[i+1]);
}
last_name[last_name_count - 1] = last_name_letter;
last_name = last_name +
}
{
last_name = last_name +
}
first_name[0] = toupper(first_name[0]);
last_name[0] = toupper(last_name[0]);
}
// This void function is for outputting your pig latin names
void
{
string pig_latin_name = first_name +
cout <<
spaces();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.