【发布时间】:2021-10-17 05:42:08
【问题描述】:
所以我没有长时间编码所以我不是那么有经验,我最近在 replit.com 上遇到了一个问题,控制台会打印出来:
error CS8803: Top-level statements must precede namespace and type declarations.
using System;
有人能提出这个问题吗? 这是我的代码,任何人都想知道:
int English;
int Science;
int AverageCalc;
AverageCalc = Convert.ToInt32(Console.ReadLine());
class Program {
public static void Main (string[] args) {
Console.WriteLine("Write your math grades");
Math = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Write your english grades");
English = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Write your science grades");
Science = Convert.ToInt32(Console.ReadLine());
AverageCalc = (Math+English+Science/3);
}
}
if (AverageCalc > 80)
{
Console.WriteLine("You passed with A mark!");
}
else if (AverageCalc < 80)
{
Console.WriteLine("You passed with B mark!");
}
else if (AverageCalc < 65)
{
Console.WriteLine("You passed with C mark!");
}
else if (AverageCalc < 60)
{
Console.WriteLine("You passed with D mark!");
}
else if (AverageCalc < 55)
{
Console.WriteLine("You got lower than D mark, try better next time.");
}
【问题讨论】:
标签: c#