C# 输入百分制成绩,转换成对应的等级(优、良、中、及格、不及格)后输出
本帖最后由 773827986 于 2015-3-7 10:09 编辑int i;
Console.Write("请输入成绩:")
i=int.Parse(Console.ReadLine());
i=trunc(i/10);
Switch(i)
{
case 10:
case 9:Console.WriteLine("优");
break;
case 8:Console.WriteLine("良");
break;
case 7:Console.WriteLine("中");
break;
case 6:Console.WriteLine("及格");
break;
default:Console.WriteLine("不及格");
}
报了很多错误,求大神解答{:301_1003:}
本帖最后由 ferrice 于 2015-3-7 10:51 编辑
case 10://这报错了
sample↓
switch (day)
{
case 0 :
dayName = "Sunday";
break;
case 1 :
dayName = "Monday";
break;
case 2 :
dayName = "Tuesday";
break;
...
default :
dayName = "Unknown";
break;
} 本帖最后由 liuyzh 于 2015-3-7 12:12 编辑
楼主你看这样行不行:
using System;
namespace TestApp
{
class TestApp
{
static void Main(string[] args)
{
int i;
Console.WriteLine("请输入成绩:");
i = int.Parse(Console.ReadLine());
i = i / 10;
switch (i)
{
case 10:
case 9: Console.WriteLine("优");
break;
case 8: Console.WriteLine("良");
break;
case 7: Console.WriteLine("中");
break;
case 6: Console.WriteLine("及格");
break;
default: Console.WriteLine("不及格");
break;
}
}
}
}
页:
[1]