编一个程序,输入0—100之间的一个学生成绩分数,用switch语句输出成绩等

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication25
{
class Program
{
static void Main(string[] args)
{
int botton ;
Console.WriteLine("请输入成绩");
botton = int.Parse(Console.ReadLine());
switch (botton)
{
case 1:
Console.Write("这枚同学成绩优秀!");
break;
case 2:
Console.Write("这枚同学成绩及格!");
break;
case 3:
Console.Write("这枚同学成绩不及格啊!");
break;
}

}
}
}

怎样把输入的数字变成case1,2,3,或者怎么把case1,2,3,变成成绩范围?
新手不懂,在线求解!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace hello_world
{
    class Program
    {
        static void Main(string[] args)
        {
            int level=0;  //成绩等级
            Console.WriteLine("请输入分数");
            int i = Convert.ToInt32(Console.ReadLine());
            if (i < 60) level = 1;
            else if (i >= 60 && i < 79) level = 2;
            else if (i >= 79 && i < 89) level = 3;
            else if (i <= 100 && i >= 90) level = 4;
            else level = 5;
            
            switch (level)
            {
                case 1:
                    Console.WriteLine("你的成绩是不及格");
                    break;
                case 2:
                    Console.WriteLine("你的成绩是中等");
                    break;
                case 3:
                    Console.WriteLine("你的成绩是良好");
                    break;
                case 4:
                    Console.WriteLine("你的成绩是优秀");
                    break;
                case 5:
                    Console.WriteLine("你输入的内容不正确");
                    break;
            }
            Console.ReadKey();
        }

    }
    }

温馨提示:内容为网友见解,仅供参考
第1个回答  2014-11-27
int level; // 成绩等级
botton = int.Parse(Console.ReadLine());
if(botton<60) level=3; //60分以下不及格
else if(botton>=80) level=1; //80分以上优秀
else level=2;  // 60-80分为及格
switch (level)
{
                case 1:
                    Console.Write("这枚同学成绩优秀!");
                    break;
                case 2:
                    Console.Write("这枚同学成绩及格!");
                    break;
                case 3:
                    Console.Write("这枚同学成绩不及格啊!");
                    break;
}

本回答被提问者采纳
第2个回答  2018-12-24

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace sorce

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("请输入分数: ");

int s = int.Parse(Console.ReadLine());

s = s / 10;

switch (s)

{

case 6:Console.WriteLine("成绩及格"); break;

case 7: Console.WriteLine("成绩及格"); break;

case 8: Console.WriteLine("成绩良好"); break;

case 9: Console.WriteLine("成绩优秀"); break;

case 10: Console.WriteLine("成绩优秀"); break;

default:Console.WriteLine("成绩不及格");break;

}

Console.WriteLine("再接再厉!");

Console.ReadLine();

}

}

}


相似回答