0

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; 
	}

Edited by WaltP: Added CODE Tags -- learn to use them and to format your code properly

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by WaltP
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.