For those of you interested, here's my edited code. If anyone has pointers for how I can make it more efficient, please feel free to let me know! Thanks again for all the help!
#include <iostream>
#include <string>
usingnamespace std;
string replace_vowels (int, string);
string backwards (int, string);
int main (void)
{
char goAgain = 'y';
do
{
system ("CLS");
string first_name;
string last_name;
cout << "Please enter your first name: " << endl;
cin >> first_name;
cout << "Please enter your last name: " << endl;
cin >> last_name;
string full_name = first_name + ' ' + last_name; //concatenate strings including a space between the words.
cout << "Here's what you entered: " << full_name << endl;
int string_length = full_name.length(); //call function to determine the string length.
string new_string1 = replace_vowels (string_length, full_name); //call function to replace vowels in string.
cout << "Here's your name with the vowels replaced: " << new_string1 << endl << endl;
string backwards_name = backwards(string_length, full_name); //call function to get the name backwards.
cout << "And here's your name backwards: " << backwards_name << endl << endl;
do
{
cout << "Would you like to enter another name? (Y or N)" << endl;
cin >> goAgain;
if (goAgain != 'y' && goAgain != 'Y' && goAgain != 'n' && goAgain != 'N')
cout << "You entered an invalid option." << endl << endl;
}
while (goAgain != 'y' && goAgain != 'Y' && goAgain != 'n' && goAgain != 'N');
}
while (goAgain == 'Y' || goAgain == 'y');
system ("BREAK");
return (0);
}
string replace_vowels (int length, string full_name)
{
string replaced_letters = full_name; //gives the two strings the same characters to start
for (int i = 0; i < length; i++)
{
if (full_name[i] == 'a' || full_name[i] == 'e' || full_name[i] == 'i' || full_name[i] == 'o' || full_name[i] == 'u')
replaced_letters[i] = 'z'; //replaces the vowels in the string with 'z'
elseif (full_name[i] == 'A' || full_name[i] == 'E' || full_name[i] == 'I' || full_name[i] == 'O' || full_name[i] == 'U')
replaced_letters[i] = 'Z'; //replaces the capital vowels in the string with 'Z'
else
replaced_letters[i] = full_name[i];
}
return (replaced_letters); //returns the string with vowels replaced
}
string backwards (int length, string full_name)
{
string backwards = full_name; //gives both strings the same characters to start
for (int j = 0; j < length; j++)
backwards[length-1-j] = full_name[j]; //assigns the first letter of the original string to the last location in the backwards string, etc.
return (backwards);
}