Print Friendly and PDF
#include <iostream>
#include <conio.h>
#include<stdio.h>
#include<time.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
class user
{
public:
char name[20];
char id[20];
int age;
char gen;
char psw[20];
user()
{
// cout<<"user constructor";
}
void setperson()
{
cout<<endl<<"Enter name: ";
gets(name);
cout<<"Enter age: ";
cin>>age;
cout<<"Enter ID : ";
gets(id);
cout<<"Enter M For Male and F for Female: ";
gender:
gen=getche();
if(gen=='m'||gen=='M'||gen=='f'||gen=='F')
{
gen=toupper(gen);
}
else
{
clrscr();
cout<<"Please Enter M or F"<<endl;
goto gender;
}
}
void show()
{
cout<<endl<<"Name is "<<name<<endl<<"Age is "<<age<<endl;
if(gen=='M')
cout<<"Gender is Male"<<endl;
else
cout<<"Gender is Female"<<endl;
cout<<"Id is "<<id<<endl;
}
int namecmp(char x[20])
{
if(strcmp(x,name)==0)
return 5;
else
return 8;
}
int pswrd()
{
char k[20];
pswrda:
cout<<"Enter Admin Password: ";
gets(k);
if(strcmp(psw,k)==0)
{
clrscr();
cout<<"Thanks for Entering Right Password"<<endl;
return 5;
}
else
{
cout<<"Wrong Password"<<endl<<"Enter Again by Pressing any Key"<<endl<<"OR"<<endl<<"Press B to go Back";
char p;
p=getch();
if(p=='B' || p=='b')
goto pswrde;
goto pswrda;
}
pswrde:
return 8;
}
void setpas()
{
char p[20];
cout<<endl<<"Enter Previous Password First: ";
gets(p);
if(strcpy(p,psw)==0)
{
char a[20],p[20];
cout<<endl<<"Thanks for Entering Right Password :)"<<endl<<" Now"<<endl<<"Enter the new password: ";
gets(a);
strcpy(psw,a);
}
else
{
cout<<endl<<"Sorry Wrong Password :(" <<endl<<"Good Bye"<<endl;
}
}
};
class student : public user
{
public:
int roll;
int semester;
float gpa;
char prog[10];
char section;
student()
{
strcpy(psw, "12345");
}
int idcmp(char x[20])
{
if(strcmp(x,id)==0)
return 5;
else
return 8;
}
int rollcmp(int a)
{
if(a==roll)
return 5;
else
return 8;
}
void setstudent()
{
cout<<endl<<"Enter Roll no: ";
cin>>roll;
cout<<endl<<"Enter Semester no: ";
cin>>semester;
cout<<endl<<"Enter program: ";
cin>>prog;
cout<<endl<<"Enter Section: ";
section=getche();
section=toupper(section);
}
void nagirsps(char n[20],int a,char g,char i[20],int r,int s,char p[20],char se)
{
strcpy(name,n);
age=a;
gen=g;
strcpy(id,i);
roll=r;
semester=s;
strcpy(prog,p);
section=se;
} void shows()
{
cout<<endl<<"Roll no is "<<roll<<endl<<"Semester is "<<semester<<endl<<"Program is "<<prog<<endl<<"Section is "<<section<<endl;
}
};
class professor : public user
{
public:
char dep[20];
int scale;
char degree;
professor()
{
}
void nagidsd(char n[20],int a,char g,char i[20],char d[20],int s, char de)
{
strcpy(name,n);
age=a;
gen=g;
strcpy(id,i);
degree=de;
scale=s;
strcpy(dep,d);
void setprofessor()
{
cout<<endl<<"Enter Scale: ";
cin>>scale;
cout<<endl<<"Press M for masters "<<endl<<"Press P for Phd"<<endl;
degre:
degree=getche();
if(degree=='m' || degree=='M'|| degree=='p' || degree=='P')
{
degree=toupper(degree);
cout<<degree;
}
else
goto degre;
cout<<endl<<"Enter Department: ";
gets(dep);
}
void setscale()
{
scalea:
cout<<endl<<"Enter Scale: ";
int a;
cin>>a;
if(a<0 || a>31)
{
cout<<endl<<"Invalid Input :("<<endl;
goto scalea;
}
scale=a;
}
char deg()
{
return degree;
}
int depcmp(char p[20])
{
if(strcmp(p,dep)==0)
return 5;
else
return 8;
}
int idcmp(char x[20])
{
if(strcmp(x,id)==0)
return 5;
else
return 8;
}
void showp()
{
cout<<endl<<"Department is "<<dep;
cout<<endl<<"Scale is "<<scale;
if(degree=='M')
cout<<endl<<"Degree is Masters";
else
cout<<endl<<"Degree is PHD";
}
};
class admin : public user
{
public:
char post[20];
admin()
{
strcpy(psw,"1234");

strcpy(post, "");
// cout<<"admin constructor";
}
void setadmin()
{
cout<<endl<<"Enter Post: ";
gets(post);
}
void showa()
{
cout<<endl<<"Post is "<<post;
}
};
int main ()
{
while(1)
{
man:
clrscr();
cout<<"Press R to Register Students"<<endl;
cout<<"Press P to Add Professor"<<endl;
cout<<"Press S to Search"<<endl;
char a;
a=getch();
admin adm;
professor pr[50];
pr[40].nagidsd("Imran Khalil",28,'M',"csitoop","csit",18, 'M');
pr[41].nagidsd("Maam Ansa",34,'F',"englishfun","english",19, 'P');
pr[42].nagidsd("Mazhar Rathore",29,'M',"discrete","Maths",20, 'M');
pr[43].nagidsd("Shahid Rasul",38,'M',"Senior","Csit",22, 'P');
student st[50];
st[40].nagirsps("Ahmad",18,'M',"uoscssa12",13,2,"bscs",'a');
st[41].nagirsps("Taimoor",21,'M',"uoscssa12",27,2,"bscs",'a');
st[42].nagirsps("Falak",19,'M',"a12",17,2,"bscs",'a');
st[43].nagirsps("Nabila",34,'f',"uoscssa12",60,2,"bscs",'a');
switch(a)
{
case 'R':
if(adm.pswrd()==5)
{
wrn:
clrscr();
int b=0;
cout<<endl<<"Enter the number of Students to Register: ";
cin>>b;

if(b>0)
{
int c=0;
while(c<b)
{
cout<<"Enter The Record for student no: "<<c+1;
st[c].setperson();
st[c].setstudent();
clrscr();
cout<<"You Entered"<<endl;
st[c].show();
st[c].shows();
getch();
clrscr();
c++;
}
}
else
goto wrn;
}
break;
case 'P':
if(adm.pswrd()==5)
{
int nop=0;
cout<<endl<<"Enter the number of Professor to Register: ";
cin>>nop;
int prp=0;
while(prp<nop)
{
cout<<"Enter The Record for Professor no: "<<prp+1;
pr[prp].setperson();
pr[prp].setprofessor();
clrscr();
cout<<"You Entered"<<endl;
pr[prp].show();
pr[prp].showp();
getch();
clrscr();
prp++;
}
}
break;
case 'S':
search_again:
clrscr();
cout<<"Press P for Professor Search"<<endl;
cout<<"Press S for Student Search"<<endl;
cout<<"Press B to Go Back"<<endl;
char t;
t=getch();
if(t=='P' || t=='p')
{
sp:
int r=0;
char y[20];
char x;
clrscr(); //sta
cout<<endl<<"Press I to Search by ID"<<endl;
x=getch();
if(x=='i' || x=='I')
{
cout<<"Enter Id of Professor You want to search: ";
gets(y);
while(r<50)
{
if(pr[r].idcmp(y)==5)
{
pr[r].show();
pr[r].showp();
}
}
cout<<endl<<"Sorry Your Given ID is not in our Database :("<<endl<<"Press S to Search Professor Again"<<endl<<"Or"<<endl<<endl<<" .....Press any key to go to Main Menu....... "<<endl;
char e;
e=getch();
if(e=='s' || e=='S')
goto sp;
out:
}
}
//END OF PROFESSOR SEARCH
}
else if(t=='s' || t=='S')
{
cout<<"Press I to Search Student by ID"<<endl;
char c;
c=getch();
if(c=='i' || c=='I')
{
ss:
int r=0;
char y[20];
cout<<"Enter Id of Student You want to search: ";
gets(y);
while(r<50)
{
if(st[r].idcmp(y)==5)
{
st[r].show();
st[r].shows();
}
cout<<endl<<"Sorry Your Given ID is not in our Database :("<<endl<<"Press S to Search Student Again"<<endl<<"Or"<<endl<<endl<<" .....Press any key to go to Main Menu....... "<<endl;
char e;
e=getch();
if(e=='s' || e=='S')
goto ss;
sout:
}
else if(t=='b' || t=='B')
goto man;
else
goto search_again;
break;
case 'Q':
exit();
break;
default:
cout<<"default"<<endl;
}
}
}
getch();
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: