Hi everyone. I got a few projects from school today. The last one I need to do is make a program were the user enters a vowel from the keyboard. If it is a vowel display "Ok, if not... dispaly "Please enter a vowel. I have the basis of the program down and it compiles and works fine. I am having problems figuring out how to store the Vowels though. At first I though an Enum would work being
enum Vowel { A, a E, e, I, i, O, o ,U ,u
but I get one of two errors being that "A is undefined and the other being that there are two many enum points.
I changed the enum to just declaring chars but that dosen't work either nor does an array.
Does anyone have any idea as to how I can store the vowels so I can refrence them in the "for" statements?
#include <string>
#include <iostream>
usingnamespace std;
int vowel;
char vowels = A, a, E, e, I, i, O, o, U, u;
int main()
{
cout << "Please enter a vowel: " << endl;
cin >> vowel;
if(vowel == vowels)
{
cout << "Ok" << endl;
}
if(vowel != vowels)
{
cout << "Please enter a vowel" << endl;
}
return 0;
}
Aside from that, at line 7, you should probably create and use an array. What you have there won't work. Below is a tutorial on arrays that should teach you everything you need to know to use your array. http://cplusplus.com/doc/tutorial/arrays/
I wouldn't check for lower AND uppercase characters - just convert it using some simple ASCII knowledge. A do-while loop seems more elegant in this particular case, too.