1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
#include "PartbQ1header.h"
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
//==============================================================================
//
//Student class
//
//==============================================================================
Student::Student()
{
strcpy(StudentID," ");
strcpy(Name," ");
strcpy(SkillArea," ");
StudentType = 0;
NoOfSubjects = 0;
Result = 0;
}
Student::Student(char id[7], char *nam, char *skill, char type,int num, char re)
{
strcpy(StudentID,id);
strcpy(Name,nam);
strcpy(SkillArea,skill);
StudentType = type;
NoOfSubjects = num;
Result = re;
}
char *Student::get_id ()
{
return StudentID;
}
void Student::set_id(char id[7])
{
strcpy(StudentID,id) ;
}
char Student::get_type()
{
return StudentType;
}
void Student::set_type(char type)
{
StudentType = type;
}
int Student::get_nosub()
{
return NoOfSubjects;
}
void Student::set_nosub(int num)
{
NoOfSubjects = num;
}
char Student::get_result()
{
return Result;
}
void Student::set_result(char re)
{
Result = re;
}
void Student::display()
{
cout<<setiosflags(ios::left)
<<setw(6)<<StudentID
<<setw(40)<<Name
<<setw(10)<<StudentType
<<setw(15)<<SkillArea
<<setw(10)<<NoOfSubjects
<<Result
<<endl;
}
ifstream& operator>>(ifstream& in, Student& stud)
{
in.get(stud.StudentID,7);
in.getline(stud.Name,40,'*');
in>>stud.StudentType;
in.getline(stud.SkillArea,20,'*');
in>>stud.NoOfSubjects;
in>>stud.Result;
in.ignore(80,'\n');
return in;
}
void ENTER_RESULTS()
{
char date[11], StudentID[7],id[7], *Name, StudentType, *SkillArea, Result,temp[80];
int i, NoOfSubjects, count;
bool again;
ifstream infile;
ofstream outfile;
infile.open("STUDENT.DAT",ios::in);
if(infile.fail())
{
cout<<"File does not exist.\n";
exit(1);
}
infile.getline(date,11);
infile.ignore(5,'\n');
cout<<date;
Student *staff[SIZE];
count = 0;
while(!infile.eof())
{
Student *tep = new Student;
infile>>*tep;
staff[count] = tep;
staff[count]->display();
count++;
}
infile.close();
}
int main()
{
ENTER_RESULTS();
cout<<endl;
system("pause");
return 0;
}
|