// ******************** DEVELOPED BY *************************
// ******************** CPPTUTE"S *****************************
#include <stdlib.h>
#include <conio.h>
#include <fstream.h>
#include <iostream.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>
int op,rol; //Global Variable
class student
{
public:
char name[30],fname[20];
int age;
int subno;
char subname[5][10];
int cls;
int mark[10],maxmark[20],roll,maxtotal,total;
float avg,per;
char grade[2],grade1[2];
int rank;
student() //Constructor
{
strcpy(grade,"P");
strcpy(grade1,"P");
}
void enter();
void reading();
void writing();
void display();
int check(int,int);
void copy(int);
};
int pass(int s,int m) //to find the average
{
return((s*100)/m);
}
void student::enter() //to read the details of students
{
setbkcolor(CYAN);
int x=5,y=13,a=20,z=13,b=35,c=13;
again:cleardevice();
rectangle(70,65,375,65);
gotoxy(10,4);
settextstyle(4,0,1);
outtextxy(170,10,"ENTER STUDENT DETAILS");
rectangle(10,40,620,420);
outtextxy(18,40,"Name");
gets(name);
gotoxy(18,6);
line(130,100,350,100);
outtextxy(18,75,"Father Name");
gets(fname);
line(425,65,455,65);
gotoxy(55,4);
settextstyle(4,0,1);
outtextxy(390,40,"Age");
cin>>age;
gotoxy(10,8);
settextstyle(4,0,1);
line(65,130,90,130);
outtextxy(18,105,"Class");
cin>>cls;
gotoxy(22,8);
settextstyle(4,0,1);
line(160,130,190,130);
outtextxy(120,105,"Roll");
cin>>roll;
total=0;
settextstyle(4,0,1);
gotoxy(28,10);
line(205,162,230,162);
outtextxy(18,135,"Enter the no of subject");
cin>>subno;
outtextxy(18,160,"Subject");
for(int i=0;i<subno;i++)
{
gotoxy(x,y);
cin>>subname[i];
y++;
}
outtextxy(100,160,"Enter the marks");
total=0;maxtotal=0;
for( i=0;i<subno;i++)
{
gotoxy(a,z);
cin>>mark[i];
total+=mark[i];
z++;
}
int r;
outtextxy(240,160,"Enter the maxmarks");
for( i=0;i<subno;i++)
{
gotoxy(b,c);
cin>>maxmark[i];
maxtotal+=maxmark[i];
r=pass(mark[i],maxmark[i]);
if(r<35)
{
strcpy(grade,"F");
strcpy(grade1,"F");
}
c++;
}
avg=r;
if(check(roll,cls)==0) //Checking for exsisting records
{ cleardevice();
outtextxy(150,90,"Already Exists");
delay(1000);
getch();
goto again;
}
}
void student::display() //To display the details
{
cleardevice();
settextstyle(7,0,1);
char agee[20],classs[20],rolll[20],totall[20],avgg[20];
itoa(age,agee,10);
itoa(cls,classs,10);
itoa(roll,rolll,10);
itoa(total,totall,10);
itoa(avg,avgg,10);
outtextxy(18,40,"Name");
outtextxy(100,40,name);
outtextxy(18,80,"Roll");
outtextxy(100,80,rolll);
outtextxy(18,120,"Age");
outtextxy(100,120,agee);
outtextxy(18,160,"Class");
outtextxy(100,160,classs);
outtextxy(18,200,"Total");
outtextxy(100,200,totall);
outtextxy(18,240,"Average");
outtextxy(100,240,avgg);
getch();
}
int student::check(int r,int c) //seraching records from a file
{
student s;
ifstream in("stude.dat",ios::binary);
while(in.read((char *)&s,sizeof(s)))
{
if(s.roll==r && s.cls==c)
{
in.close();
return 0;
}
if(in.eof())
break;
}
in.close();
return 1;
}
void student::writing() // Write the records in to the file
{
cleardevice();
ofstream out("stude.dat",ios::app|ios::binary);
student s;
s.enter();
out.write((char *)&s,sizeof(s));
out.close();
}
void student::reading() //Reading records from a file
{
student s;
cleardevice();
ifstream in("stude.dat",ios::binary);
int f=0;
while(in.read((char *)&s,sizeof(s)))
{
f=1;
s.display();
if (in.eof())
break;
}
if(f==0)
outtextxy(150,90,"No record exixt");
getch();
in.close();
}
void rep_disp() //To display report card
{
student s;
int f=0;
ifstream in("reportt.dat",ios::binary);
while(in.read((char *)&s,sizeof(s)))
{
if(s.roll==rol)
{
f=1;
char agee[20],classs[20],rolll[20],totall[20],maxtotall[20],gradee[20];
cleardevice();
setlinestyle(SOLID_LINE,1,1);
rectangle(0,0,getmaxx(),getmaxy());
rectangle(0,10,getmaxx(),getmaxy()-10);
outtextxy(140,70,"CPPTUTE");
delay(1000);
outtextxy(270,70," CPPTUTE ");
delay(1000);
outtextxy(360,70," CPPTUTE");
delay(1000);
outtextxy(180,100,"(Cpptute)");
delay(1000);
outtextxy(180,170,"PROGRESS REPORT");
delay(1000);
outtextxy(210,200,"2005-2006");
setcolor(6);
outtextxy(140,270,"\"Good education is a real treasure\"");
delay(1000);
cleardevice();
setcolor(15);
setlinestyle(DOTTED_LINE,1,1);
outtextxy(140,10,"CPPTUTE CPPTUTE CPPTUTE,CPPTUTE");
rectangle(10,40,620,420);
line(75,65,350,65);
outtextxy(18,40,"Name");
setcolor(4);
outtextxy(85,40,strupr(s.name));
setcolor(15);
line(150,100,350,100);
outtextxy(18,75,"Father Name");
setcolor(4);
outtextxy(160,75,strupr(s.fname));
setcolor(15);
line(425,65,465,65);
outtextxy(390,40,"Age");
itoa(s.age,agee,10);
setcolor(4);
outtextxy(430,40,agee);
setcolor(15);
line(65,130,100,130);
outtextxy(18,105,"Class");
itoa(s.cls,classs,10);
setcolor(4);
outtextxy(73,105,classs);
setcolor(15);
line(160,130,190,130);
outtextxy(120,105,"Roll");
itoa(s.roll,rolll,10);
setcolor(4);
outtextxy(165,105,rolll);
setcolor(15);
outtextxy(20,155,"Subject");
outtextxy(170,155,"Marks");
outtextxy(300,155,"Max. Marks");
setcolor(4);
int x=20,y=185,a=190,z=185,b=335,c=185;
char markk[30],maxx[30];
for(int i=0;i<s.subno;i++)
{
gotoxy(x,y);
itoa(s.mark[i],markk,10);
itoa(s.maxmark[i],maxx,10);
outtextxy(x,y,strupr(s.subname[i]));
outtextxy(a,z,markk);
outtextxy(b,c,maxx);
y+=20;
z+=20;
c+=20;
}
setcolor(15);
itoa(s.total,totall,10);
outtextxy(x,y+30,"Total");
setcolor(4);
outtextxy(a,z+30,totall);
itoa(s.maxtotal,maxtotall,10);
outtextxy(b,c+30,maxtotall);
setcolor(15);
outtextxy(480,230,"Grade");
setcolor(4);
outtextxy(540,230,s.grade1);
setcolor(15);
itoa(s.rank,maxtotall,10);
outtextxy(480,270,"Rank");
setcolor(4);
outtextxy(540,270,maxtotall);
setcolor(15);
outtextxy(480,155,"Comment");
setcolor(4);
if(strcmp(s.grade,"P")==0)
{
if(s.avg>=90)
outtextxy(470,185,"Exceptional");
else
if(s.avg>=80 && s.avg<90)
outtextxy(470,185,"Excellent");
else
if(s.avg>=70 && s.avg<80)
outtextxy(470,185,"Good");
else
if(s.avg>=60 && s.avg<70)
outtextxy(470,185,"Not Bad");
else
if(s.avg<60)
outtextxy(470,185,"Very less");
}
else
outtextxy(450,185,"Work very hard");
break;
}
}
setcolor(15);
if(f==0)
outtextxy(150,90,"Not found");
getch();
in.close();
}
void top(student s) //To display the details of topper
{
char chh,classs[20];
cleardevice();
gotoxy(10,2);
setlinestyle(DOTTED_LINE,1,1);
rectangle(90,90,500,300);
line(420,180,490,180);
line(420,230,470,230);
settextstyle(4,0,4);
setcolor(4);
outtextxy(170,100,"CERTIFICATE") ;
setcolor(15);
settextstyle(4,0,2);
outtextxy(100,150,"\"This to certify that Master/Miss") ;
setcolor(4);
outtextxy(430,150,s.name);
setcolor(15);
outtextxy(100,200, "has shown excellent performance in" );
itoa(s.cls,classs,10);
setcolor(4);
outtextxy(430,200,classs);
setcolor(15);
outtextxy(470,200,"\"");
gotoxy(10,3);
settextstyle(4,0,1);
getch();
}
void arrange(student s[],int n) //Arrange the records based on their total
{
int i,j;
student t,cd[100];
ofstream out("reportt.dat",ios::binary);
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
if(s[i].total<s[j].total)
{
t=s[i];
s[i]=s[j];
s[j]=t;
}
}
int k=1;
for(i=0;i<n;i++)
{
if(strcmp(s[i].grade,"P")==0)
{
if(s[i].avg>=90)
strcpy(s[i].grade1,"A");
else
if(s[i].avg>=80 && s[i].avg<90)
strcpy(s[i].grade1,"B");
else
if(s[i].avg>=70 && s[i].avg<80)
strcpy(s[i].grade1,"C");
else
if(s[i].avg>=60 && s[i].avg<70)
strcpy(s[i].grade1,"D");
else
if(s[i].avg<60)
strcpy(s[i].grade1,"E");
s[i].rank=k++;
}
else
s[i].rank=0;
out.write((char *)&s[i],sizeof(s[i]));
}
out.close();
if(op==3)
rep_disp();
else
if(op==4)
top(s[0]);
else if(op==6)
{
student t;
int r=0,x=130,y=130;
cleardevice();
outtextxy(210,50,"Rank List");
outtextxy(180,90,"S.No");
outtextxy(300,90,"Name");
ifstream in("reportt.dat",ios::binary);
int i=0;
char ch[2];
while(in.read((char *)&t,sizeof(t)))
{
i++;
itoa(i,ch,10);
outtextxy(180,x,ch);
outtextxy(300,y,t.name);
x+=20;
y+=20;
if(in.eof())
break;
}
getch();
in.close();
}
}
void student::copy(int c)
{
student t[100],s;
int i=0,f=0;
ifstream in("stude.dat",ios::binary);
cleardevice();
if(op==5)
{
outtextxy(210,50,"Failure Details");
outtextxy(180,90,"S.No");
outtextxy(300,90,"Name");
}
int r=0,x=130,y=130;
char ch[20];
while(in.read((char *)&s,sizeof(s)))
{
if(s.cls==c)
{
t[i++]=s;
f=1;
}
if(op==5 && s.cls==c && strcmp(s.grade,"F")==0)
{
r++;
itoa(r,ch,10);
outtextxy(180,x,ch);
outtextxy(300,y,s.name);
x+=20;
y+=20;
}
}
in.close();
if(f==1)
arrange(t,i);
else
outtextxy(150,90,"Not found");
}
void than()
{
for(int h=0;h<16;h++)
{
cleardevice();
setcolor(h);
settextstyle(4,0,4);
outtextxy(200,90,"Thank You");
outtextxy(180,150,"God bless us all");
outtextxy(100,200,"Inspiration is the key to success");
delay(100);
}
getch();
exit(0);
}
void main()
{
student s;
int cs;
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "../bgi");
for(int j=0;j<180;j+=5)
{
setcolor(j);
outtextxy(j,200,"Cpptute");
delay(100);
cleardevice();
setbkcolor(CYAN);
settextstyle(4,0,4);
outtextxy(100,80,"RESULT $$$");
outtextxy(330,80,"PROCESSOR");
outtextxy(160,160,"DEVELOPED BY");
}
for(int k=470;k>330;k-=10)
{
setcolor(k);
outtextxy(j,200,"Cpptute");
outtextxy(k,200,"sethia");
delay(100);
cleardevice();
setbkcolor(CYAN);
settextstyle(4,0,4);
outtextxy(100,80,"RESULT $$$");
outtextxy(330,80,"PROCESSOR");
outtextxy(160,160,"DEVELOPED BY");
}
for(int h=0;h<12;h+=3)
{
setcolor(h);
settextstyle(4,0,4);
outtextxy(100,80,"RESULT $$$");
outtextxy(330,80,"PROCESSOR");
outtextxy(160,160,"DEVELOPED BY");
outtextxy(j,200,"Cpptute");
outtextxy(k,200,"sethia");
// outtextxy(((j+50+k)/2),200,"&");
delay(100);
}
settextstyle(7,0,1);
outtextxy(180,300,"Special Thanks To");
outtextxy(195,330," Cpptute.blogspot.com");
setlinestyle(DOTTED_LINE,1,1);
for(h=180;h<420;h+=20)
{
line(180,360,h,360);
delay(200);
}
delay(1000);
cleardevice();
while(1)
{
cleardevice();
setbkcolor(3);
setcolor(WHITE);
setlinestyle(DOTTED_LINE,1,1);
rectangle(0,0,getmaxx(),getmaxy());
settextstyle(3,0,1);
outtextxy(190,35,"RESULT PROCESSOR");
rectangle(190,80,410,270);
outtextxy(200,90,"1.Display");
outtextxy(200,110,"2.Add records");
outtextxy(200,130,"3.Report card");
outtextxy(200,150,"4.Toppers detaiLs");
outtextxy(200,170,"5.Failure details");
outtextxy(200,190,"6.Rank List");
outtextxy(200,210,"7.Exit");
outtextxy(200,230,"Enter ur option");
settextstyle(4,0,1);
line(380,257,395,257);
gotoxy(49,16);
cin>>op;
switch(op)
{
case 1: s.reading();
break;
case 2: s.writing();
break;
case 3: cleardevice();
setlinestyle(DOTTED_LINE,1,1);
settextstyle(7,0,1);
outtextxy(250,35,"REPORT CARD");
rectangle(190,80,460,270);
outtextxy(220,120,"Enter the class:");
gotoxy(47,9);
cin>>cs;
outtextxy(220,169,"Enter the roll number:");
gotoxy(56,12);
cin>>rol;
s.copy(cs);
break;
case 4: cleardevice();
setlinestyle(DOTTED_LINE,1,1);
settextstyle(4,0,2);
outtextxy(250,35,"TOPPERS DETAILS");
rectangle( 190,80,450,270);
outtextxy(220,120,"Enter the class:");
gotoxy(47,9);
cin>>cs;
s.copy(cs);
break;
case 5: cleardevice();
setlinestyle(DOTTED_LINE,1,1);
settextstyle(4,0,2);
outtextxy(250,35,"FAILURES DETAILS");
rectangle(190,80,450,270);
outtextxy(220,120,"Enter the class:");
gotoxy(47,9);
cin>>cs;
s.copy(cs);
break;
case 6: cleardevice();
setlinestyle(DOTTED_LINE,1,1);
settextstyle(4,0,2);
outtextxy(250,35,"RANK LIST");
rectangle(190,80,450,270);
outtextxy(220,120,"Enter the class:");
gotoxy(47,9);
cin>>cs;
s.copy(cs);
break;
case 7: than();
exit(0);
default:cleardevice();
outtextxy(150,150,"Invalid Option");
delay(1000);
}
}
}