After you enter a name, it just prints out "Would you like to convert another name? (y/n) " it doesn't even give the user a chance to enter anything and it doesn't print out the converted name. It just ends...Why?
#include<iostream>
#include<string>
using namespace std;
void conversion(char name[]);
void lowercase(char name[]);
int main()
{
char first[100], last[100];
char answer;
cout << "Enter a name (first then last): ";
cin >> first, last;
lowercase(first);
lowercase(last);
conversion(first);
conversion(last);
cout << "Would you like to convert another name? (y/n) ";
cin >> answer;
while (answer == 'Y' || answer == 'y')
{cout << "Enter a name (first then last): ";
cin >> first, last;
lowercase(first);
lowercase(last);
conversion(first);
conversion(last);
cout << endl;
cout << "Would you like to convert another name? (y/n)";
cin >> answer;
if (answer == 'N' || answer == 'n')
{break;}
}
return 0;
}
void conversion(char name[])
{
if (name[0] == 'a' || name[0] == 'e' || name[0] == 'i' || name[0] == 'o' || name[0] == 'u')
{toupper(name[0]);
cout << name << "way ";}
else {
for (int i = 0; i < 100; i++)
{ toupper(name[0]);
name = name + name[i];
}
cout << name << "ay ";}
}
void lowercase(char name[])
{
int i = 1;
while (name[i] != '\0')
{
name[i] = tolower(name[i]);
i++;
}
}