-8

嗨,有人可以帮助我在我的程序中它包含以下错误:在第 (3,26) 行中,它在第 (5,22) 行中显示“{预期”,在第 (5,22) 行中显示“{预期”,最后在第 (5,22) 行中它显示“无效的令牌';' 在类、结构或接口成员声明中”。

我真的无法确定如何修复错误,因为我刚开始编写 c#。任何帮助将不胜感激!谢谢!

using System;

namespace GradeEvaluation;
{
    public class Program;
    {
        public static void Main(string[] args)
        {
            string name;
            int grade, finalGrade;

            Console.WriteLine("What is your name: ");
            name = Console.ReadLine();
            Console.WriteLine("What is your final grade: ");
            finalGrade = Convert.ToDouble(Console.ReadLine());

            if(finalGrade >= 0 && finalGrade <= 59.9)
            Console.WriteLine("{0} Your final transmuted grade is 5", name);
            else if(finalGrade >= 60 && finalGrade <= 63.99)
            Console.WriteLine("{0} Your final transmuted grade is 3", name);
            else if(finalGrade >= 64 && finalGrade <= 67.99)
            Console.WriteLine("{0} Your final transmuted grade is 2.75", name);
            else if(finalGrade >= 68 && finalGrade <= 71.99)
            Console.WriteLine("{0} Your final transmuted grade is 2.5", name);
            else if(finalGrade >= 72 && finalGrade <= 75.99)
            Console.WriteLine("{0} Your final transmuted grade is 2.25", name);
            else if(finalGrade >= 76 && finalGrade <= 79.99)
            Console.WriteLine("{0} Your final transmuted grade is 2", name);
            else if(finalGrade >= 80 && finalGrade <= 83.99)
            Console.WriteLine("{0} Your final transmuted grade is 1.75", name);
            else if(finalGrade >= 84 && finalGrade <= 87.99)
            Console.WriteLine("{0} Your final transmuted grade is 1.5", name);
            else if(finalGrade >= 88 && finalGrade <= 91.99)
            Console.WriteLine("{0} Your final transmuted grade is 1.25", name);
            else if(finalGrade >= 92 && finalGrade <= 100)
            Console.WriteLine("{0} Your final transmuted grade is 1", name);
        }
    }
}
4

3 回答 3

5

namespace GradeEvaluation;
{
    public class Program;

所以,像

namespace GradeEvaluation
{
    public class Program
于 2013-11-11T06:46:46.830 回答
5

删除这些分号 ( ;):

namespace GradeEvaluation;
{
    public class Program;
    {

编译器错误是你的朋友!

阅读错误消息通常会为问题提供令人难以置信的洞察力:

在此处输入图像描述

第 3 行,第 26 列是您的第一个不正确的分号所在的位置:namespace GradeEvaluation;编译器告诉您“不,我在{这里期待一个,而不是您拥有的任何东西!”

第 5 行第 25 列更加明确!( public class Program;) 它告诉您您提供了一个无效的令牌 ( ;),而且它再次期待一个{.

于 2013-11-11T06:45:59.547 回答
5

删除;命名空间和类名之后的:

namespace GradeEvaluation
{
    public class Program
    {
        ...
    }
}
于 2013-11-11T06:46:10.497 回答