我想输入学生的标识和标记到数组中。问题陈述是,如果用户输入学生的身份证,那么应该显示该学生的马克。以下是我的代码到目前为止。你可以帮我吗?从数组中检索数据
int [] mark = new int [5] ;
string [] studentsid = new string [5];
string userInput = "";
bool found = false;
int i = 0;
string[] answer = new string[5];
for (i = 0; i < answer.Length; i++)
{
Console.WriteLine("Enter Student " + (i + 1) + " 's ID Number: ");
studentsid[i] = Console.ReadLine();
Console.WriteLine("Enter student" + (i + 1) + "'s mark: ");
mark[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("Enter one of you student's id number");
userInput = Console.ReadLine();
if (studentsid[i].ToUpper() == userInput.ToUpper())
{
found = true;
Console.WriteLine(mark[i]);
}
if (mark[i] >=85 && mark[i] <= 100)
{
Console.WriteLine("Distinction");
}
Console.ReadKey();
你遇到的实际问题是什么? –
这是一个很好的*开始*的问题,但特别是当你正在学习编码时,你需要更好地识别实际问题。请参阅http://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question – BradleyDotNET
你正在代码中你想要的部分没有循环找到正确的ID,其余的代码看起来不错(ish)。 – fvu