Write a program that asks the user to type a vowel from the keyboard. If the character entered is a vowel, display “OK”; if it is not a vowel, display an error message. Be sure to allow both uppercase and lowercase vowels. The program continues until the user types ‘!’.
My code is as follows:
char vowel;
Console.WriteLine("enter vowel , A, E, I, O, U ");
vowel = Convert.ToChar(Console.ReadLine());
while (vowel != '!')
{
switch (vowel)
{
case 'A':
case 'a':
break;
case 'E':
case 'e':
break;
case 'I':
case 'i':
break;
case 'O':
case 'o':
break;
case 'U':
case 'u':
break;
default:
break;
}
Console.WriteLine("okay, vowel type is {0} yay!!", vowel);
Console.WriteLine("enter vowel , A, E, I, O, U ");
vowel = Convert.ToChar(Console.ReadLine());
}
{
Console.WriteLine("error try again");
}
}
question from:
https://stackoverflow.com/questions/65831344/is-there-a-way-to-fix-my-code-so-that-it-runs-a-loop-in-the-c-sharp-program 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…