choosesubject c# switch
程序员文章站
2023-11-25 13:40:46
复制代码 代码如下: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!");
}
}