constint NUM_SCORES = 6;
typedefstruct
{
int day;
int month;
int year;
} Date;
struct Student
{
int number;
Date dob;
float scores[NUM_SCORES];
}; Student student;
constint MAX_ITEMS = 10;
struct ListType
{
int length;
int info[MAX_ITEMS];
}; ListType list;
struct ItemType
{
int aStudent;
int findStudent;
};
void readstudent(void);
void writestudent(void);
int _tmain(int argc, _TCHAR* argv[])
{
Student student [15];
ListType list;
list.length = 0;
ifstream in ("StudentFile.txt");
while(!in.eof())
for (int i = 0; i < 15; i++)
{
in >> student[i].number >> student[i].dob.day >> student[i].dob.month >> student[i].dob.year
>> student[i].scores[0]
>> student[i].scores[1]
>> student[i].scores[2]
>> student[i].scores[3]
>> student[i].scores[4]
>> student[i].scores[5];
}
cout << "The Class List Is: " << endl;
cout << "Name " << "\t" << "Date" << "\t\t" << "Scores" << endl;
for (int i = 0; i < 15; i++)
{
cout << student[i].number << "\t" << student[i].dob.day << "/" << student[i].dob.month << "/" << student[i].dob.year << "\t"
<< student[i].scores[0]
<< student[i].scores[1]
<< student[i].scores[2]
<< student[i].scores[3]
<< student[i].scores[4]
<< student[i].scores[5] << endl;
}
in.close();
return 0;
}
void readstudent(ifstream &in, ItemType &aStudent)
{
in >> student.number;
in >> student.dob.day >> student.dob.month >> student.dob.year;
for (int i = 0; i < NUM_SCORES; i++)
{
in >> student.scores[i];
}
}
void writestudent(ItemType student)
{
//not sure what to put here
}
i've answered most of the questions i was given but i'm confused on the last few:
one of the things i have to do is assign list.info[list.length] to aStudent - i was given some code so i will have to change the program here but not sure what to do
another is call method writeStudent() to output an element of list.info of type student.
last thing is enter a student number to search for a student into findStudent.number and if the student is found call writeStudent() to output findStudent.