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
|
#include<fstream.h>
#include<stdlib.h>
class variable
{
protected:
struct student
{
char name[100],course[100],id[10],gender;
int dob,mob,yob,age,ic;
double cgpa,marks[10];
}std[100];
int i;
};
class student:public variable
{
private:
public:
void reg()
{
i=1;
std[i].dob=std[i].mob=std[i].yob=0;
cout<<"Enter Student Name : ";
cin.ignore();
cin.getline(std[i].name,100);
cout<<"Enter Student IC : ";
cin.ignore();
cin>>std[i].ic;
cout<<"Enter Student Gender : ";
cin.ignore();
cin>>std[i].gender;
cout<<"Enter Student Course : ";
cin.ignore();
cin.get(std[i].course,100);
cout<<"Student Borthday : "<<endl;;
cout<<"Date : ";
cin.ignore();
cin>>std[i].dob;
cout<<"Month : ";
cin.ignore();
cin>>std[i].mob;
cout<<"Year : ";
cin.ignore();
cin>>std[i].yob;
i++;
}
void dpl()
{
for(int a=1;a<=i;a++)
{
cout<<"Student Name : "<<std[a].name<<endl;
cout<<"Student ID : "<<std[a].id<<endl;
cout<<"Student IC : "<<std[a].ic<<endl;
cout<<"Student Gender : "<<std[a].gender<<endl;
cout<<"Student Course : "<<std[a].course<<endl;
cout<<"Student Birthday : "<<std[a].dob<<"/"<<std[a].mob<<"/"<<std[a].yob<<endl;
cout<<"============================================="<<endl;
}
}
};
class exam:public student
{
};
class slt_menu:public exam
{
private:
int choice;
char reply;
public:
void mainmenu()
{
cout<<"\t\t\t*******************************************"<<endl;
cout<<"\t\t\t* Extreme Technology *"<<endl;
cout<<"\t\t\t* Collage *"<<endl;
cout<<"\t\t\t* Student Detail System *"<<endl;
cout<<"\t\t\t*******************************************"<<endl;
cout<<"\n\t\t\t1.Student Data System"<<endl;
cout<<"\t\t\t2.Student Examination System"<<endl;
cout<<"\t\t\t3.Exit From This Program"<<endl;
cout<<"\n\t\t\tEnter Your Choice : ";
do{
cin>>choice;
switch(choice)
{
case 1:
{
smenu();
break;
}
case 2:
{
break;
}
case 3:
{
exit(1);
break;
}
default:
{
cout<<"\t\t\tYou Have Enter Invalid Input!!!Enter Again!!!"<<endl;
cout<<"\t\t\tEnter Your Choice Again : ";
}
}
}
while(choice!=1 || choice !=2 ||choice !=3);
}
void smenu()
{
student st;
cout<<"\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\t\t\t~ Student Data ~"<<endl;
cout<<"\t\t\t~ System ~"<<endl;
cout<<"\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\n\t\t\t1.Student Registration"<<endl;
cout<<"\t\t\t2.Display Student Detail"<<endl;
cout<<"\t\t\t3.Seacrh Student Detail"<<endl;
cout<<"\t\t\t4.Return To Main Menu"<<endl;
cout<<"\n\t\t\tEnter YOur Choice : ";
cin>>choice;
do{
switch(choice)
{
case 1:
{
do{
reg();
cout<<"Do You Wish To Add More Data??"<<endl;
cin>>reply;
}while(reply=='Y'||reply=='y');{}
cout<<"Do You Want To Save & Return To Main Menu"<<endl;
cin>>reply;
if(reply=='Y'||reply=='y')
{
ofstream input("student_details.txt");
input.write((char*)&st,sizeof(student));
input.close();
mainmenu();
}
break;
}
case 2:
{
ifstream toread("student_details.txt");
toread.read((char*)&st,sizeof(student));
while(toread)
{
toread.read((char*)&st,sizeof(student));
}
toread.close();
dpl();
}
case 3:
{
}
case 4:
{
mainmenu();
}
default:
{
cout<<"\t\t\tYou Have Enter Invalid Input!!!Enter Again!!!"<<endl;
cout<<"\t\t\tEnter Your Choice Again : ";
cin>>choice;
}
}
}while(choice!=1||choice!=2||choice!=3||choice!=4);
}
};
void main()
{
slt_menu m;
m.mainmenu();
}
|