为什么我收到错误无效的表达式术语'如果'?

时间:2016-05-16 17:31:43

标签: c#

计算获得10名学生成绩的计划 该计划如下。

a

1 个答案:

答案 0 :(得分:1)

您的for循环缺少右括号,因此不期望在循环中间表达式中遇到if语句。

编辑 - 这是一个格式正确的代码块。

Console.WriteLine(" Enter your scoreCA: ");
double scoreCA = double.Parse(Console.ReadLine());
Console.WriteLine(" Enter your scoreExam: ");
double scoreExam = double.Parse(Console.ReadLine());
double[] scoreTotal;
for (i=0, i<10, i++)
{
    scoreTotal[i] = scoreExam + scoreCA;
    if (scoreTotal < 0 || scoreTotal > 100)
    {
        Console.WriteLine("invalid");
    }
    else if (scoreTotal <= 100 && scoreTotal > 69)
    {
        Console.WriteLine("Your Grade is A");
    }
    else if (scoreTotal < 70 && scoreTotal > 59)
    {
        Console.WriteLine("Your grade is B");
    }
    else if (scoreTotal < 60 && scoreTotal > 59)
    {
        Console.WriteLine("Your grade is C");
    }
    else if (scoreTotal < 50 && scoreTotal > 44)
    {
        Console.WriteLine("Your grade is D");
    }
    else (scoreTotal < 45 && scoreTotal >= 0);
    {
        Console.WriteLine("Your grade is F");
        Console.ReadKey();
    }
}