Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
917 views
in Technique[技术] by (71.8m points)

terminal - Is there a way to fix my code so that it runs a loop in the c# program?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...