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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
#include <Windows.h>
#include <iomanip>
using namespace std;
class Person
{
protected:
char firstname[20],lastname[20],gender[20],address[20];
int Id,age,phonenumber;
public:
int main_menu();
void get();
void set();
void record_search(int);
};
class student:public Person
{
private:
float QuizMark,TestMark,AssignmentMark,MidtermMark,finalMark,personalTutorId;
char ModuleName[20];
float total,average,GP;
public:
int std_menu();
void set_record(int);
void record_header();
void get_record();
void update();
void delete_std();
int max_record(int);
int min_record(int);
void record_search(int);
void sort_record();
void show_net();
void show();
void show_paseed();
void show_failed();
};
class PersonalTutor:public Person
{
private:
int personalId,number_student;
char dept_name,designation;
public:
int per_menu();
void add_per(int);
void list_personal(void);
void delete_personal();
void update();
void assignment();
void list_student();
void list_passed();
void list_failed();
};
int main()
{
int IK;
student obj;
PersonalTutor obj;
int dd,s,p;
do{
s=obj.std_menu();
int choice;
system("cls");
cout<<endl<<endl<<endl;
cout<<"\t Gulf College student and personal totur system"<<endl;
cout<<"\t==> press [1] for Student Menu"<<endl;
cout<<"\t==> press [2] for Personal Tutor Menu"<<endl;
cout<<"\t==> press [3] for Exit"<<endl<<endl;
cout<<"\t Enter your choice \t";
cin>>choice;
return choice;
}
switch(dd){
case 1:
int Ik;
system("cls");
cout<<endl<<endl<<endl;
cout<<" \t Gulf College student and personal totur system"<<endl;
cout<<"\t==> Enter 1 for add new student records"<<endl;
cout<<"\t==> Enter 2 for view all student records"<<endl;
cout<<"\t==> Enter 3 for upbate student records"<<endl;
cout<<"\t==> Enter 4 for Delete student records"<<endl;
cout<<"\t==> Enter 5 for show student who gets the max GPA"<<endl;
cout<<"\t==> Enter 6 for show student who gets the min GPA"<<endl;
cout<<"\t==> Enter 7 for find student by ID"<<endl;
cout<<"\t==> Enter 8 for sort records by GPA"<<endl;
cout<<"\t==> Enter 9 for show all student who did not assign personal totor"<<endl;
cout<<"\t==> Enter 10 for show all student who assign personal totor"<<endl;
cout<<"\t==> Enter 11 for show list of passed student"<<endl;
cout<<"\t==> Enter 12 for show list of failed student"<<endl;
cout<<"\t==> Enter 13 for exit"<<endl<<endl;
cout<<"Enter your chouce[]";
cin>>Ik;
switch (Ik);
{
case 1: obj.set_record(int); break;
case 2: obj.record_header();break;
case 3: obj.get_record();break;
case 4: obj.update();break;
case 5: obj.delete_std();break;
case 6: obj.max_record(int);break;
case 7: obj.min_record(int);break;
case 8: obj.record_search(int);break;
case 9: obj.sort_record();break;
case 10: obj.show_net();break;
case 11: obj.show();break;
case 12: obj.show_paseed();break;
case 13: obj.show_failed();break;
default:
cout<<"Invalid Choise";
}
void student::set_record(int rec)
{
char op;
student std;
ofstream add("person.txt",ios::app);
do{
cout<<"Enter the ID = ";
cin>>Id;
cout<<"enter First Name of Person=\n";
cin>>firstname;
cout<<"enter the Last Name for person=\n";
cin>>lastname;
cout<<"enter Gender of Person=\n";
cin>>gender;
cout<<"enter Adsress of Person=\n";
cin>>address;
cout<<"enter Age of Person=\n";
cin>>age;
cout<<"enter Phone Number of Person=\n";
cin>>phonenumber;
cout<<"Enter Module Name=";
cin>>ModuleName;
cout<<"Enter Quiz Mark=";
cin>>QuizMark;
cout<<"Enter Test Mark=";
cin>>TestMark;
cout<<"Enter Assignment Mark=";
cin>>AssignmentMark;
cout<<"Enter Midterm Mark=";
cin>>MidtermMark;
cout<<"enter final Mark=";
cin>>finalMark;
cout<<"Enter personal Tutor Id=";
cin>>personalTutorId;
total=QuizMark+TestMark+AssignmentMark+MidtermMark+finalMark;
average=(total/5)*100;
//GP=;
add.write((char *) &rec, sizeof(rec));
cout<<endl<< "More Records";
cin>>op;
}while (op=='y' || op=='Y');
add.close();
}
void student::record_header(){
student std;
char op:
ifstream
rrr("person.txt",ios::binary);
system("cls");
if(!rrr)
{
cerr<<"File opening error";
exit(0);
}
while (rrr.read((char *) &std, sizeof(std)))
{
cout<<setw(15)<<std.id<<setw(15)<<std.firstname<<setw(15)<<std.lastname<<setw(15)<<std.gender<<setw(15)<<std.address<<setw(15)<<std.age<<setw(15)<<std.phonenumber<<endl;;
}
rrr.close();
getch();
}
void student::update()
{
student std;
int id;
logn int rn=0, t=0;
fstream
rrr("person.txt",ios::binary | ios::in|ios::out);
system("cls");
if(!rrr)
{
cerr<<"file opening error";
exit(0);
}
cout<<"Enter the student Id=";
cin>>id;
while(rrr.read((char*) &std, sizeof(std)))
{
if(std.id==id)
{
cout<<std.id<<"\t"<<std.firsname<<"\t"<<std.lastname<<"\t"<<std.gender<<"\t"<<std.address<<"\t"<<std.age<<"\t"<<std.phonnumber<<endl;
rn=rn*sizeof(std);
rrr.seekp(rn);
cout<<"Enter the ID = ";
cin>>std.Id;
cout<<"enter First Name of Person=\n";
cin>>std.firstname;
cout<<"enter the Last Name for person=\n";
cin>>std.lastname;
cout<<"enter Gender of Person=\n";
cin>>std.gender;
cout<<"enter Adsress of Person=\n";
cin>>std.address;
cout<<"enter Age of Person=\n";
cin>>std.age;
cout<<"enter Phone Number of Person=\n";
cin>>std.phonenumber;
cout<<"Enter Module Namk=";
cin>>std.ModuleName;
cout<<"Enter Quiz Mark=";
cin>>std.QuizMark;
cout<<"Enter Test Mark=";
cin>>std.TestMark;
cout<<"Enter Assignment Mark=";
cin>>std.AssignmentMark;
cout<<"Enter Midterm Mark=";
cin>>std.MidtermMark;
cout<<"enter final Mark=";
cin>>std.finalMark;
cout<<"Enter personal Tutor Id=";
cin>>std.personalTutorId;
rrr.write ((char *) &std,sizeof(std));
rrr.close();
t=1;
}
rn++;
}
if(t==0)
{
cout<<"Record not found"<<end;
getch();
}
}
void student::delete_std()
{
student std;
int id;
long int rn=0,t=0;
fstream
rrr("person.txt",ios::binary|ios::in|ios::out);
system("cls");
if(!rrr)
{
cerr<<"File opening error";
exit(0);
}
cout<<"Enter the student Id=";
cin>>id;
while(rrr.read((char*) &std, sizeof(std)))
{
if(std.id==id)
{
cout<<"Record is:"<<std.id<<"\t"<<std.firsname<<"\t"<<std.lastname<<"\t"<<std.gender<<"\t"<<std.address<<"\t"<<std.age<<"\t"<<std.phonnumber<<endl;
if(std.id=='*')
{
cout<<"Rrcords already id"<<endl;
t=1;
}
else
{
rn=rn*sizeof(std);
rrr.seekp(rn);
std.id='*';
rrr.write((char*) &std,sizeof(std));
cout<<endl<<"Record is ID for deletion"<<endl;
rrr.close();
t=1;
}
}
rn++
}
if(t==0)
cout<<"Record not found"<<endl;
getch();}
void student::max_record(int){
student std;
maxmk=0;
long int rn=0,t=0;
fstream
rrr("person.txt",ios::binary|ios::in|ios::out);
system("cls");
if(!rrr){
cerr<<"File opening error";
exit(0);}
while(rrr.read((char*) &std,sizeof(std))){
if(maxmk <= total){
return id;}
rrr.close();
t=1;}
rn++
getch();}
void student::min_record(int){
student std;
minmk=0;
long int rn=0,t=0;
fstream
rrr("person.txt",ios::binary|ios::in|ios::out);
system("cls");
if(!rrr){
cerr<<"File opening error";
exit(0);}
if (minmk < maxmk){
return id;}
rrr.close();
t=1;}
rn++
getch();}
void student::record_search(int){
student std;
int id;
long int rn=0,t=0;
ifstream rrr("person.txt",ios::binary);
system("cls");
if(!rrr){
cerr<<"File opening error";
exit(1);}
cout<<"Enter the student ID=";
cin>>id;
while (rrr.read((char*) &std,sizeof(std))){
if (std.id==id){
rn=(rn-1)*sizeof(std);
rrr.seekg(rn);
cout<<std.id<<"\t"<<std.firsname<<"\t"<<std.lastname<<"\t"<<std.gender<<"\t"<<std.address<<"\t"<<std.age<<"\t"<<std.phonnumber<<endl;
rrr.close();
t=1;}
rn++;}
if(t==0){
cout<<"Recod not found"<<endl;
getch();}
getch();}
void student::sort_record(){
student std;
getch();}
case 2:
break;
case 3:
exit(0);
default:
cout<<endl<<" Wrong input";}
}while(1);
getch(0);}
|