Defining the find(student[] st,
int itemcount) method to find the record in the list. This method asks the user
to enter the id of the student record. Then this id is checked to make sure it
really exists. If the record is found, the information of the target student
will be displayed. If the record is not found the message "The record
doesn't exist." will be displayed.
static void find(student[] st, int itemcount)
{
string id;
Console.Write("Enter student's ID:");
id=Console.ReadLine();
int index=search(st,id.ToString(),itemcount);
if (index != -1)
{
Console.Write("{0,-5}{1,-20}{2,-5}", st[index].stnumber, st[index].stname, st[index].sex);
Console.Write("{0,-5}{1,-5}{2,-5}", st[index].quizz1, st[index].quizz2, st[index].assigment);
Console.Write("{0,-5}{1,-5}{2,-5}", st[index].midterm, st[index].final, st[index].total);
Console.WriteLine();
}
else Console.WriteLine("The record doesn't exits.");
}
static void find(student[] st, int itemcount)
{
string id;
Console.Write("Enter student's ID:");
id=Console.ReadLine();
int index=search(st,id.ToString(),itemcount);
if (index != -1)
{
Console.Write("{0,-5}{1,-20}{2,-5}", st[index].stnumber, st[index].stname, st[index].sex);
Console.Write("{0,-5}{1,-5}{2,-5}", st[index].quizz1, st[index].quizz2, st[index].assigment);
Console.Write("{0,-5}{1,-5}{2,-5}", st[index].midterm, st[index].final, st[index].total);
Console.WriteLine();
}
else Console.WriteLine("The record doesn't exits.");
}
No comments:
Post a Comment