欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

choosesubject c# switch

程序员文章站 2022-07-22 10:05:41
复制代码 代码如下:using system; class choosesubject {     static void main...
复制代码 代码如下:

using system;
class choosesubject
{
    static void main()
    {
        int i;
        string str;
        console.writeline ("please choose your favorite subjects:-1 is quit.");
        console.writeline ("1.chinese.");
        console.writeline ("2.maths.");
        console.writeline ("3.english.");
        console.writeline ("4.physical.");
        console.writeline ("-1 is quit.");
        do
        {
            str=console.readline ();
            i=int32.parse (str);
            switch(i)
            {
                case 1:
                    console.writeline ("you like chinese very much.");
                    break;
                case 2:
                    console.writeline ("you like maths very much.");
                    break;
                case 3:
                    console.writeline ("you like english very much.");
                    break;
                case 4:
                    console.writeline ("you like physical very much.");
                    break;
                case -1:
                    break;
                default:
                    console.writeline ("i'm sorry.you can't choose this subject.");
                    break;
            }

        }while(i!=-1);
        console.writeline ("byebye!");
    }
}