我是 C# 编程的新手,我正在为一个正在创建 3 个问题测试的朋友做一个控制台应用程序。我需要获取前 5 名用户的姓名并显示他们的成绩,但我不知道该怎么做。你能帮我吗谢谢。这是代码:
string Name, yn;
int points = 0;
do{
Console.WriteLine("Please enter your fullname here:");
Name = Console.ReadLine();
Console.WriteLine(" ");
Console.WriteLine("Hello " + Name + " Welcome to this simple test.");
Console.WriteLine(" ");
Console.WriteLine("1) What is 5 + 6?");
Console.WriteLine(" a)10");
Console.WriteLine(" b)30");
Console.WriteLine(" c)11");
Console.Write("Answer: ");
string QAns1 = "C";
string MyAns1 = Console.ReadLine().ToUpper();
Console.Clear();
if (MyAns1 == QAns1)
{
Point++;
}
Console.WriteLine("2) What is the first letter of Apple?");
Console.WriteLine(" a)A");
Console.WriteLine(" b)c");
Console.WriteLine(" c)a");
Console.Write("Answer: ");
string QAns2 = "A";
string MyAns2 = Console.ReadLine().ToUpper();
Console.Clear();
if (MyAns2 == QAns2)
{
Point++;
}
Console.WriteLine("3) What is the plural word of tooth?");
Console.WriteLine(" a)tentacles");
Console.WriteLine(" b)Teeth");
Console.WriteLine(" c)tooths");
Console.Write("Answer: ");
string QAns3 = "B";
string MyAns3 = Console.ReadLine().ToUpper();
Console.Clear();
if (MyAns3 == QAns3)
{
Point++;
}
Console.WriteLine(" Mr. " + Name + " your final score is " + Point + "/10 ");
Console.WriteLine(" Do you want to try again? ");
yn = Console.ReadLine().ToUpper();
}while (yn== "Y");
Console.WriteLine("Thank you for using our program.");