Project on Annual Result
C++ Project on Annual Result System. Here i will give you complete code to download this project.
Source Code
//**********************************************************
// PROJECT ANNUAL RESULT
//**********************************************************
//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>
#include <iomanip.h>
//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU & DRAW
// LINES, BOXES, ETC.
//**********************************************************
class MENU
{
public :
void MAIN_MENU(void) ;
void CLEAR(int) ;
void LINE_HOR(int, int, int, char) ;
void LINE_VER(int, int, int, char) ;
void BOX(int,int,int,int,char) ;
} ;
//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS RELATED TO STUDENT
//**********************************************************
class STUDENT
{
public :
void ADDITION(void) ;
void MODIFICATION(void) ;
void DELETION(void) ;
void LIST(void) ;
void MARKSHEET(void) ;
void INTRODUCTION(void) ;
private :
void DELETE(int,int) ;
void BOX(void) ;
int LAST_ROLLNO(int) ;
void DISPLAY_LIST(int) ;
int FOUND_ROLLNO(int, int) ;
int FOUND_CLASS(int) ;
void DISPLAY_RECORD(int, int) ;
int RECORDNO(int, int) ;
int Class, rollno ;
char name[26], fname[26], address[36] ;
} ;
//**********************************************************
// THIS FUNCTION CONTROL ALL THE FUNCTIONS IN THE MAIN MENU
//**********************************************************
void MENU :: MAIN_MENU(void)
{
char ch ;
while (1)
{
clrscr() ;
BOX(8,4,73,22,178) ;
LINE_VER(5,21,9,178) ;
LINE_VER(5,21,72,178) ;
BOX(10,5,71,21,219) ;
LINE_VER(6,20,11,219) ;
LINE_VER(6,20,70,219) ;
BOX(12,6,69,20,218) ;
gotoxy(33,7) ;
cout <<"ANNUAL RESULT" ;
LINE_HOR(33,45,8,22) ;
gotoxy(31,10) ;
cout <<"1. INTRODUCTION" ;
gotoxy(31,11) ;
cout <<"2. NEW STUDENT" ;
gotoxy(31,12) ;
cout <<"3. MARK SHEET" ;
gotoxy(31,13) ;
cout <<"4. LIST OF STUDENTS" ;
gotoxy(31,14) ;
cout <<"5. MODIFY STUDENT" ;
gotoxy(31,15) ;
cout <<"6. DELETE STUDENT" ;
gotoxy(31,16) ;
cout <<"0. QUIT" ;
gotoxy(31,18) ;
cout <<"ENTER YOUR CHOICE:" ;
cin>>ch;
// getch() ;
if (ch == 27 || ch == '0')
return ;
else
if (ch == '1')
{
STUDENT ST ;
ST.INTRODUCTION() ;
}
else
if (ch == '2')
{
STUDENT ST ;
ST.ADDITION() ;
}
else
if (ch == '3')
{
STUDENT ST ;
ST.MARKSHEET() ;
}
else
if (ch == '4')
{
STUDENT ST ;
ST.LIST() ;
}
else
if (ch == '5')
{
STUDENT ST ;
ST.MODIFICATION() ;
}
else
if (ch == '6')
{
STUDENT ST ;
ST.DELETION() ;
}
}
}
//**********************************************************
// THIS FUNCTION DELETES THE GIVEN ROW NO. ON THE SCREEN
//**********************************************************
void MENU :: CLEAR(int row)
{
gotoxy(3,row) ;
cout <<" " ;
}
//
//**********************************************************
// THIS FUNCTION DRAWS THE HORRIZONTAL LINE
//**********************************************************
void MENU :: LINE_HOR(int column1, int column2, int row, char c)
{
for ( column1; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout <<c ;
}
}
//**********************************************************
// THIS FUNCTION DRAWS THE VERTICAL LINE
//**********************************************************
void MENU :: LINE_VER(int row1, int row2, int column, char c)
{
for ( row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout <<c ;
}
}
//**********************************************************
// THIS FUNCTION DRAWS THE BOX
//**********************************************************
void MENU :: BOX(int column1, int row1, int column2, int row2, char c)
{
char ch=218 ;
char c1, c2, c3, c4 ;
char l1=196, l2=179 ;
if (c == ch)
{
c1=218 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 179 ;
}
else
{
c1=c ;
c2=c ;
c3=c ;
c4=c ;
l1 = c ;
l2 = c ;
}
gotoxy(column1,row1) ;
cout <<c1 ;
gotoxy(column2,row1) ;
cout <<c2 ;
gotoxy(column1,row2) ;
cout <<c3 ;
gotoxy(column2,row2) ;
cout <<c4 ;
column1++ ;
column2-- ;
LINE_HOR(column1,column2,row1,l1) ;
LINE_HOR(column1,column2,row2,l1) ;
column1-- ;
column2++ ;
row1++ ;
row2-- ;
LINE_VER(row1,row2,column1,l2) ;
LINE_VER(row1,row2,column2,l2) ;
}
//**********************************************************
// THIS FUNCTION GIVES INTRODUCTION ABOUT THIS PROJECT
//**********************************************************
void STUDENT :: INTRODUCTION(void)
{
clrscr() ;
MENU m ;
m.BOX(1,2,80,24,218) ;
gotoxy(16,8) ;
cout <<"THIS PROGRAM HAS FACILITY OF KEEPING ABOUT 5000" ;
gotoxy(16,9) ;
cout <<"STUDENT RECORDS , ACCEPTING THE MARKS OF 3 TERMS" ;
gotoxy(16,10) ;
cout <<"AND CALCULATING FINAL RESULT WITH REMARKS" ;
gotoxy(28,13) ;
cout <<"MARKS CALCULATED AS ----" ;
gotoxy(28,15) ;
cout <<"20% OF FIRST TERM" ;
gotoxy(28,16) ;
cout <<"20% OF SECOND TERM" ;
gotoxy(28,17) ;
cout <<"60% OF THIRD TERM" ;
gotoxy(27,23) ;
cout <<"Press any key to continue" ;
getch() ;
}
//**********************************************************
// THIS FUNCTION RETURNS 0 IF GIVEN CLASS RECORD NOT FOUND
//**********************************************************
int STUDENT :: FOUND_CLASS(int sclass)
{
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(STUDENT)))
{
if (Class == sclass)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}
//**********************************************************
// THIS FUNCTION RETURNS 0 IF GIVEN ROLL NO. NOT FOUND
//**********************************************************
int STUDENT :: FOUND_ROLLNO(int sclass, int srollno)
{
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(STUDENT)))
{
if (Class == sclass && rollno == srollno)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}
//**********************************************************
// THIS FUNCTION RETURNS THE LAST ROLLNO. OF THE GIVEN CLASS
//**********************************************************
int STUDENT :: LAST_ROLLNO(int sclass)
{
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(STUDENT)))
{
if (Class == sclass)
count++ ;
}
file.close() ;
return count ;
}
//**********************************************************
// THIS FUNCTION RETURNS THE RECORD NO. OF THE GIVEN CLASS &
// ROLLNO. OF THE STUDENT
//**********************************************************
int STUDENT :: RECORDNO(int sclass, int srollno)
{
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(STUDENT)))
{
count++ ;
if (Class == sclass && rollno == srollno)
break ;
}
file.close() ;
return count ;
}
//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD OF STUDENT FOR GIVEN
// CLASS AND ROLL NO.
//**********************************************************
void STUDENT :: DISPLAY_RECORD(int sclass, int srollno)
{
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(STUDENT)))
{
if (Class == sclass && rollno == srollno)
{
gotoxy(5,5) ;
cout <<"Class : " <<Class ;
gotoxy(5,6) ;
cout <<"Rollno. : " <<rollno ;
gotoxy(5,8) ;
cout <<"Student's Name : " <<name ;
gotoxy(5,9) ;
cout <<"Father's Name : " <<fname ;
gotoxy(5,10) ;
cout <<"Address : " <<address ;
break ;
}
}
file.close() ;
}
//**********************************************************
// THIS FUNCTION ADDS STUDENT RECORDS IN STUDENT FILE
//**********************************************************
void STUDENT :: ADDITION(void)
{
MENU m ;
int valid=0, t2=0, sclass=0, srollno=0 ;
char ch, t1[5], sname[26], sfname[26], saddress[36] ;
do
{
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
m.LINE_HOR(2,79,22,196) ;
gotoxy(72,3) ;
cout <<"<0>=EXIT" ;
gotoxy(27,3) ;
cout <<"ADDITION OF STUDENT RECORD" ;
gotoxy(5,6) ;
cout <<"Class : " ;
gotoxy(5,7) ;
cout <<"Roll no. : " ;
gotoxy(5,9) ;
cout <<"Name : " ;
gotoxy(5,10) ;
cout <<"Father's name : " ;
gotoxy(5,11) ;
cout <<"Address : " ;
do
{
valid = 1 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"ENTER CLASS OF THE STUDENT (1..12)" ;
m.CLEAR(6) ;
gotoxy(5,6) ;
cout <<"Class : " ;
gets(t1) ;
t2 = atoi(t1) ;
sclass = t2 ;
if (t1[0] == '0')
return ;
if (sclass < 1 || sclass > 12)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
srollno = LAST_ROLLNO(sclass) + 1 ;
gotoxy(16,7) ;
cout <<srollno ;
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(9) ;
gotoxy(5,23) ;
cout <<"ENTER NAME OF THE STUDENT" ;
gotoxy(5,9) ;
cout <<"Name : " ;
gets(sname) ;
if (sname[0] == '0')
return ;
if (strlen(sname) < 1 || strlen(sname) > 25)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7Enter Correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(10) ;
gotoxy(5,23) ;
cout <<"ENTER FATHER'S NAME OF THE STUDENT" ;
gotoxy(5,10) ;
cout <<"Father's name : " ;
gets(sfname) ;
if (sfname[0] == '0')
return ;
if (strlen(sfname) < 1 || strlen(sfname) > 25)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7Enter Correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(11) ;
gotoxy(5,23) ;
cout <<"ENTER ADDRESS OF THE STUDENT" ;
gotoxy(5,11) ;
cout <<"Address : " ;
gets(saddress) ;
if (saddress[0] == '0')
return ;
if (strlen(saddress) < 1 || strlen(saddress) > 35)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7Enter Correctly (Range: 1..35)" ;
getch() ;
}
} while (!valid) ;
m.CLEAR(23) ;
do
{
m.CLEAR(14) ;
gotoxy(5,14) ;
cout <<"Do you want to save (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'Y')
{
Class = sclass ;
rollno = srollno ;
strcpy(name,sname) ;
strcpy(fname,sfname) ;
strcpy(address,saddress) ;
fstream file ;
file.open("STUDENT1.DAT", ios::app) ;
file.write((char *) this, sizeof(STUDENT)) ;
file.close() ;
}
do
{
m.CLEAR(16) ;
gotoxy(5,16) ;
cout <<"Do you want to Add more (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
} while (ch == 'Y') ;
}
//**********************************************************
// THIS FUNCTION DISPLAYS THE LIST OF THE STUDENTS FOR THE
// GIVEN CLASS
//**********************************************************
void STUDENT :: DISPLAY_LIST(int sclass)
{
clrscr() ;
int row=7, found=0, flag=0 ;
char ch ;
MENU m ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
m.LINE_HOR(2,79,6,196) ;
m.LINE_HOR(2,79,22,196) ;
gotoxy(32,3) ;
cout <<"LIST OF STUDENTS" ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(2,5) ;
cprintf(" CLASS ROLL NO. STUDENT NAME FATHER'S NAME ADDRESS ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(STUDENT)))
{
if (Class == sclass || sclass == 0)
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(4,row) ;
cout <<Class ;
gotoxy(12,row) ;
cout <<rollno ;
gotoxy(20,row) ;
cout <<name ;
gotoxy(37,row) ;
cout <<fname ;
gotoxy(55,row) ;
cout <<address ;
if ( row == 21 )
{
flag = 1 ;
row = 7 ;
gotoxy(5,23) ;
cout <<"Press any key to continue or Press <ESC> to exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
m.LINE_HOR(2,79,6,196) ;
m.LINE_HOR(2,79,22,196) ;
gotoxy(32,3) ;
cout <<"LIST OF STUDENTS" ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(2,5) ;
cprintf(" CLASS ROLL NO. STUDENT NAME FATHER'S NAME ADDRESS ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
}
else
row++ ;
}
}
if (!found)
{
gotoxy(5,10) ;
cout <<"\7Records not found" ;
}
if (!flag)
{
gotoxy(5,23) ;
cout <<"Press any key to continue..." ;
getch() ;
}
file.close () ;
}
//**********************************************************
// THIS FUNCTION GIVES CLASS TO DISPLAY LIST OF STUDENTS
//**********************************************************
void STUDENT :: LIST(void)
{
clrscr() ;
int t2, sclass, valid ;
char t1[5] ;
MENU m ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
m.LINE_HOR(2,79,22,196) ;
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(6) ;
gotoxy(5,6) ;
cout <<"Enter Class or Press <ENTER> to see all : " ;
gets(t1) ;
t2 = atoi(t1) ;
sclass = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
if (sclass < 1 || sclass > 12)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
DISPLAY_LIST(sclass) ;
}
//**********************************************************
// THIS FUNCTION DRAW BOX FOR CREATING MARK SHEET
//**********************************************************
void STUDENT :: BOX(void)
{
MENU m ;
m.BOX(1,2,80,24,219) ;
m.LINE_HOR(2,79,4,219) ;
gotoxy(33,3) ;
cout <<"ANNUAL RESULT" ;
m.LINE_HOR(2,79,6,196) ;
m.LINE_VER(9,15,28,176) ;
m.LINE_VER(9,15,41,176) ;
m.LINE_VER(9,15,54,176) ;
m.LINE_VER(9,15,68,176) ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(2,7) ;
cprintf(" SUBJECT I TERM II TERM III TERM FINAL ") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
int row=9 ;
for (int i=1; i<=5; i++)
{
gotoxy(5,row) ;
cout <<"Marks in Subject " <<i ;
row++ ;
}
m.LINE_HOR(2,79,8,196) ;
m.LINE_HOR(2,79,14,196) ;
gotoxy(5,15) ;
cout <<"TOTAL" ;
m.LINE_HOR(2,79,16,196) ;
gotoxy(3,23) ;
cout <<"PRINCIPAL" ;
gotoxy(72,23) ;
cout <<"TEACHER" ;
}
//**********************************************************
// THIS FUNCTION CREATING MARK SHEET AND DISPLAY IT
//**********************************************************
void STUDENT :: MARKSHEET(void)
{
MENU m ;
int valid, t2, sclass, srollno ;
char t1[5] ;
do
{
clrscr() ;
valid = 1 ;
gotoxy(5,23) ;
cout <<"ENTER CLASS OF THE STUDENT (1..12) or <ENTER> FOR HELP" ;
gotoxy(5,6) ;
cout <<"Class : " ;
gets(t1) ;
t2 = atoi(t1) ;
sclass = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
LIST() ;
}
if ((sclass < 1 || sclass > 12) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
if (!FOUND_CLASS(sclass) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7CLASS RECORD NOT FOUND" ;
getch() ;
return ;
}
} while (!valid) ;
do
{
clrscr() ;
gotoxy(5,6) ;
cout <<"Class : " <<sclass ;
valid = 1 ;
gotoxy(5,23) ;
cout <<"ENTER ROLL NO. OF THE STUDENT or <ENTER> FOR HELP" ;
m.CLEAR(8) ;
gotoxy(5,8) ;
cout <<"Roll no. : " ;
gets(t1) ;
t2 = atoi(t1) ;
srollno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
DISPLAY_LIST(sclass) ;
}
if (srollno < 1 && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
if (!FOUND_ROLLNO(sclass,srollno) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ROLL NO. NOT FOUND" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
while (file.read((char *) this, sizeof(STUDENT)))
if (Class == sclass && rollno == srollno)
break ;
file.close() ;
m.BOX(1,2,80,24,219) ;
m.LINE_HOR(2,79,4,196) ;
int row=6, marks1[5], marks2[5], marks3[5] ;
gotoxy(3,3) ;
cout <<"MARKS FOR THE THREE TERMS" ;
gotoxy(40,3) ;
cout <<"Student Name : " <<name ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(5,5) ;
cprintf("ENTER MARKS FOR THE 1st TERM") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
for (int i=0; i<5; i++)
{
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(row) ;
gotoxy(5,row) ;
cout <<"Marks in " <<i+1 <<" Subject : " ;
gets(t1) ;
t2 = atoi(t1) ;
marks1[i] = t2 ;
if (t1[0] == '0')
return ;
if (marks1[i] < 1 || marks1[i] > 100)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
row++ ;
}
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(5,row) ;
cprintf("ENTER MARKS FOR THE 2nd TERM") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
row++ ;
for (i=0; i<5; i++)
{
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(row) ;
gotoxy(5,row) ;
cout <<"Marks in " <<i+1 <<" Subject : " ;
gets(t1) ;
t2 = atoi(t1) ;
marks2[i] = t2 ;
if (t1[0] == '0')
return ;
if (marks2[i] < 1 || marks2[i] > 100)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
row++ ;
}
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(5,row) ;
cprintf("ENTER MARKS FOR THE 3nd TERM") ;
textcolor(LIGHTGRAY) ; textbackground(BLACK) ;
row++ ;
for (i=0; i<5; i++)
{
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(row) ;
gotoxy(5,row) ;
cout <<"Marks in " <<i+1 <<" Subject : " ;
gets(t1) ;
t2 = atoi(t1) ;
marks3[i] = t2 ;
if (t1[0] == '0')
return ;
if (marks3[i] < 1 || marks3[i] > 100)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
row++ ;
}
clrscr() ;
BOX() ;
gotoxy(3,5) ;
cout <<"Class : " <<Class <<" Roll no. : " <<rollno <<" Name : " <<name ;
row = 9 ;
int compart=0, disting=0, total1=0, total2=0, total3=0 ;
float totalf=0.0, t=0.0, average=0.0 ;
for (i=0; i<5; i++)
{
gotoxy(33,row) ;
cout <<marks1[i] ;
gotoxy(47,row) ;
cout <<marks2[i] ;
gotoxy(61,row) ;
cout <<marks3[i] ;
t = marks1[i] * 0.2 ;
t = t + (marks2[i] * 0.2) ;
t = t + (marks3[i] * 0.6) ;
gotoxy(73,row) ;
cout <<setprecision(2) <<t ;
total1 = total1 + marks1[i] ;
total2 = total2 + marks2[i] ;
total3 = total3 + marks2[i] ;
totalf = totalf + t ;
if (t < 40)
compart = compart + 1 ;
if (t >=75)
disting = disting + 1 ;
row++ ;
}
gotoxy(33,15) ;
cout <<total1 ;
gotoxy(47,15) ;
cout <<total2 ;
gotoxy(61,15) ;
cout <<total3 ;
gotoxy(73,15) ;
cout <<setprecision(2) <<totalf ;
average = totalf / 5 ;
gotoxy(5,18) ;
cout <<"AVERAGE : " <<setprecision(2) <<average ;
gotoxy(5,19) ;
cout <<"DISTINCTION : " <<disting <<" COMPARTMENT : " <<compart ;
gotoxy(5,21) ;
if (average < 40)
cout <<"REMARKS : Failed. IIIrd Diviion" ;
else
if (average < 60)
cout <<"REMARKS : IInd Division. Promoted to next class" ;
else
cout <<"REMARKS : Ist Division. Promoted to next class" ;
gotoxy(1,2) ;
getch() ;
}
//**********************************************************
// THIS FUNCTION MODIFY THE STUDENT RECORD
//**********************************************************
void STUDENT :: MODIFICATION(void)
{
MENU m ;
int valid, t2, sclass, srollno ;
char t1[5], ch ;
do
{
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
gotoxy(23,3) ;
cout <<"MODIFICATION OF THE STUDENT RECORD" ;
valid = 1 ;
gotoxy(5,23) ;
cout <<"ENTER CLASS OF THE STUDENT (1..12) or <ENTER> FOR HELP" ;
gotoxy(5,6) ;
cout <<"Class : " ;
gets(t1) ;
t2 = atoi(t1) ;
sclass = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
LIST() ;
}
if ((sclass < 1 || sclass > 12) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
if (!FOUND_CLASS(sclass) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7CLASS RECORD NOT FOUND" ;
getch() ;
return ;
}
} while (!valid) ;
do
{
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
gotoxy(23,3) ;
cout <<"MODIFICATION OF THE STUDENT RECORD" ;
gotoxy(5,6) ;
cout <<"Class : " <<sclass ;
valid = 1 ;
gotoxy(5,23) ;
cout <<"ENTER ROLL NO. OF THE STUDENT or <ENTER> FOR HELP" ;
m.CLEAR(8) ;
gotoxy(5,8) ;
cout <<"Roll no. : " ;
gets(t1) ;
t2 = atoi(t1) ;
srollno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
DISPLAY_LIST(sclass) ;
}
if (srollno < 1 && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
if (!FOUND_ROLLNO(sclass,srollno) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ROLL NO. NOT FOUND" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
m.LINE_HOR(2,79,22,196) ;
gotoxy(23,3) ;
cout <<"MODIFICATION OF THE STUDENT RECORD" ;
DISPLAY_RECORD(sclass,srollno) ;
do
{
m.CLEAR(12) ;
gotoxy(5,12) ;
cout <<"Do you want to modify this record (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
int modified=3 ;
char sname[26], sfname[26], saddress[36] ;
m.CLEAR(12) ;
gotoxy(5,15) ;
cout <<"Name : " ;
gotoxy(5,16) ;
cout <<"Father's name : " ;
gotoxy(5,17) ;
cout <<"Address : " ;
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(15) ;
gotoxy(5,23) ;
cout <<"ENTER NAME OF THE STUDENT or <ENTER> FOR NO CHANGE" ;
gotoxy(5,15) ;
cout <<"Name : " ;
gets(sname) ;
if (sname[0] == '0')
return ;
if (strlen(sname) > 25)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7Enter Correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
if (strlen(sname) == 0)
{
modified-- ;
strcpy(sname,name) ;
gotoxy(21,15) ;
cout <<sname ;
}
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(16) ;
gotoxy(5,23) ;
cout <<"ENTER FATHER'S NAME OF THE STUDENT or <ENTER> FOR NO CHANGE" ;
gotoxy(5,16) ;
cout <<"Father's name : " ;
gets(sfname) ;
if (sfname[0] == '0')
return ;
if (strlen(sfname) > 25)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7Enter Correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
if (strlen(sfname) == 0)
{
modified-- ;
strcpy(sfname,fname) ;
gotoxy(21,16) ;
cout <<sfname ;
}
do
{
valid = 1 ;
m.CLEAR(23) ;
m.CLEAR(17) ;
gotoxy(5,23) ;
cout <<"ENTER ADDRESS OF THE STUDENT or <ENTER> FOR NO CHANGE" ;
gotoxy(5,17) ;
cout <<"Address : " ;
gets(saddress) ;
if (saddress[0] == '0')
return ;
if (strlen(saddress) > 35)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7Enter Correctly (Range: 1..35)" ;
getch() ;
}
} while (!valid) ;
if (strlen(saddress) == 0)
{
modified-- ;
strcpy(saddress,address) ;
gotoxy(21,17) ;
cout <<saddress ;
}
if (!modified)
return ;
m.CLEAR(23) ;
do
{
m.CLEAR(20) ;
gotoxy(5,20) ;
cout <<"Do you want to save (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
int recno ;
recno = RECORDNO(sclass,srollno) ;
fstream file ;
file.open("STUDENT1.DAT", ios::out | ios::ate) ;
Class = sclass ;
rollno = srollno ;
strcpy(name,sname) ;
strcpy(fname,sfname) ;
strcpy(address,saddress) ;
int location ;
location = (recno-1) * sizeof(STUDENT) ;
file.seekp(location) ;
file.write((char *) this, sizeof(STUDENT)) ;
file.close() ;
m.CLEAR(20) ;
gotoxy(5,21) ;
cout <<"\7Record Modified" ;
gotoxy(5,23) ;
cout <<"Press any key to continue..." ;
getch() ;
}
//**********************************************************
// THIS FUNCTION DELETE THE STUDENT RECORD FOR THE GIVEN
// CLASS AND ROLLNO.
//**********************************************************
void STUDENT :: DELETE(int sclass, int srollno)
{
fstream file ;
file.open("STUDENT1.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while (!file.eof())
{
file.read((char *) this, sizeof(STUDENT)) ;
if (file.eof())
break ;
if (sclass != Class || srollno != rollno)
temp.write((char *) this, sizeof(STUDENT)) ;
}
file.close() ;
temp.close() ;
file.open("STUDENT1.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(STUDENT)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(STUDENT)) ;
}
file.close() ;
temp.close() ;
}
//**********************************************************
// THIS FUNCTION GIVES CLASS AND ROLLNO. TO DELETE THE
// STUDENT RECORD
//**********************************************************
void STUDENT :: DELETION(void)
{
MENU m ;
int valid=0, t2=0, sclass=0, srollno=0 ;
char t1[5], ch ;
do
{
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
gotoxy(25,3) ;
cout <<"DELETION OF THE STUDENT RECORD" ;
valid = 1 ;
gotoxy(5,23) ;
cout <<"ENTER CLASS OF THE STUDENT (1..12) or <ENTER> FOR HELP" ;
gotoxy(5,6) ;
cout <<"Class : " ;
gets(t1) ;
t2 = atoi(t1) ;
sclass = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
LIST() ;
}
if ((sclass < 1 || sclass > 12) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
if (!FOUND_CLASS(sclass) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7CLASS RECORD NOT FOUND" ;
getch() ;
return ;
}
} while (!valid) ;
do
{
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
gotoxy(25,3) ;
cout <<"DELETION OF THE STUDENT RECORD" ;
gotoxy(5,6) ;
cout <<"Class : " <<sclass ;
valid = 1 ;
gotoxy(5,23) ;
cout <<"ENTER ROLL NO. OF THE STUDENT or <ENTER> FOR HELP" ;
m.CLEAR(8) ;
gotoxy(5,8) ;
cout <<"Roll no. : " ;
gets(t1) ;
t2 = atoi(t1) ;
srollno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
DISPLAY_LIST(sclass) ;
}
if (srollno < 1 && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ENTER CORRECTLY" ;
getch() ;
}
if (!FOUND_ROLLNO(sclass,srollno) && valid)
{
valid = 0 ;
m.CLEAR(23) ;
gotoxy(5,23) ;
cout <<"\7ROLL NO. NOT FOUND" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
m.BOX(1,2,80,24,218) ;
m.LINE_HOR(2,79,4,196) ;
m.LINE_HOR(2,79,22,196) ;
gotoxy(25,3) ;
cout <<"DELETION OF THE STUDENT RECORD" ;
DISPLAY_RECORD(sclass,srollno) ;
do
{
m.CLEAR(12) ;
gotoxy(5,12) ;
cout <<"Do you want to delete this record (y/n) " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
DELETE(sclass,srollno) ;
m.CLEAR(12) ;
gotoxy(5,21) ;
cout <<"\7Record Deleted" ;
gotoxy(5,23) ;
cout <<"Press any key to continue..." ;
getch() ;
}
//**********************************************************
// THIS IS MAIN FUNCTION CALLING MAIN MENU
//**********************************************************
void main(void)
{
MENU menu ;
menu.MAIN_MENU() ;
}
No comments :
Post a Comment