c#提问 急急急~

来源:百度知道 编辑:UC知道 时间:2024/09/18 05:30:07
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 作业3
{
class SwitchTest
{
static void Main(string[] args)
{
int a=0, i;
for (i = 1; i <= 5; i++)
{
Console.WriteLine("请输入一个百分制的数:");
Console.ReadLine();
if (a > 100 || a < 0)
{
Console.WriteLine("error");
}
else
{
a = a / 10;
}
switch (a)
{
case 10:
case 9: Console.WriteLine("优秀"); break;
case 8: Console.WriteLine("不错"); break;
case 7: Console.WriteLine("一般"

下面刚是我在我机子上做的,你看看,我把那里改了 我给你(标记)出来了……

static void Main(string[] args)
{
int a = 0, i;
for (i = 1; i <= 5; i++)
{
Console.WriteLine("请输入一个:");

a=Convert.ToInt32( Console.ReadLine());//你读入一个百分制的数应该赋给a然你下面的a就没有值可读了。我想这你是粗心了……

if (a > 100 || a < 0)
{
Console.WriteLine("error");
}
else
{
a = a / 10;

switch (a)//把switch给放到else里面,这是因为你要让符合你的条件在这里面用行
{
case 10:
case 9: Console.WriteLine("优秀"); break;
case 8: Console.WriteLine("不错"); break;
case 7: Console.WriteLine("一般"); break;