Hello.

I am making a wheel of fortune game and am getting stuck. This loop keeps repeating the first line "Incorrect input. You can only pick a vowel." Also, I can't get the phrase to read the vowel and say, "Sorry, this vowel was already revealed." If the vowel was already shown.

This is the code:

bool isVowel = true;  

	int counter; 
	char vowel; 
	int length;
	length = static_cast<int>(puzzle.size());

if (score[player] >= 250)
	{
		cout << "Player " << player + 1 << ", pick a vowel -> ";
		cin >> vowel; 
for (counter = 0; counter < length; counter++)
{
     if (vowel != 'a' || vowel != 'e' || vowel != 'i' || vowel != 'o' || vowel != 'u')
     {
	cout << "Incorrect input. You can only pick a vowel." << endl; 
	isVowel = true; 
     }
else if (phrase[counter] == vowel)
    {
         cout << "Sorry, this vowel is already revealed." << endl; 
	isVowel = true; 
    }
	else 
     {
	cout << "Congradulations player" << player + 1 << "!" << endl; 
	cout << "There are " << counter << " " << vowel << "'s in the puzzle." << endl; 
	isVowel = false; 
     }
   }
}
	else
	{
		cout << "You do not have enough money to buy a vowel." << endl; 
		isVowel = true; 
	}

Because when you enter a character, rather than checking if the character is a vowel first you enter a loop. Then you check if it's a vowel for each and every letter in the puzzle.

So, why enter the loop if the character entered is wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.