Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

//**********************************************************

//
PROJECT SCHOOL FEE ENQUIRY
//**********************************************************
#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 RELATED TO FEES
//**********************************************************
class FEE
{
public :
void ADDITION(void) ;
void MODIFICATION(void) ;
void FEE_SLIP(void) ;
void LIST(void) ;
private :
void DISPLAY(int) ;
void MODIFY_RECORD(int, float, float, float, float,
float) ;
int Class ;
float tution, pta, science, pupil, supw ;
} ;
//**********************************************************
// FUNCTION TO ADD FEE STRUCTURE IN FEE FILE
//**********************************************************
void FEE :: ADDITION(void)
{
FEE fee;
fstream file ;
file.open("FEE.DAT", ios::app) ;
for (int i=1; i<=12; i++)
{
Class
= i ;
tution = 0.0 ;
pta
= 0.0 ;
science = 0.0 ;
pupil
= 0.0 ;
supw
= 0.0 ;
file.write((char *)&fee,sizeof(fee)) ;
}
file.close() ;
MODIFY_RECORD(12,250,50,30,20,50) ;
MODIFY_RECORD(11,250,50,30,20,50) ;
MODIFY_RECORD(10,250,50,30,20,50) ;
MODIFY_RECORD(9,210,50,20,20,50) ;
MODIFY_RECORD(8,210,50,20,20,0) ;
MODIFY_RECORD(7,200,50,20,20,0) ;
MODIFY_RECORD(6,200,50,20,20,0) ;

MODIFY_RECORD(5,180,50,0,20,0)
MODIFY_RECORD(4,180,50,0,20,0)
MODIFY_RECORD(3,150,50,0,20,0)
MODIFY_RECORD(2,150,50,0,20,0)
MODIFY_RECORD(1,150,50,0,20,0)

;
;
;
;
;

}
//**********************************************************
// FUNCTION TO DISPLAY TOTAL FEE AS LIST
//**********************************************************
void FEE :: LIST(void)
{
FEE fee;
clrscr() ;
gotoxy(27,3) ;
cout <<"TOTAL FEES FOR THE CLASSES" ;
gotoxy(5,5) ;
cout <<"CLASS
TOTAL FEES" ;
float total ;
int row=8 ;
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *)&fee,sizeof(fee)))
{
total = tution + pta + science + pupil + supw ;
gotoxy(6,row) ;
cout <<Class ;
gotoxy(23,row) ;
cout <<total ;
row++ ;
}
file.close() ;
gotoxy(5,23) ;
cout <<"Press any key to continue..." ;
getch() ;
}
//**********************************************************
// FUNCTION TO DISPLAY THE RECORD FOR THE GIVEN CLASS
//**********************************************************
void FEE :: DISPLAY(int tclass)
{
FEE fee;
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *)&fee,sizeof(fee)))
{
if (Class == tclass)
{
gotoxy(5,5) ;
cout <<"Class : " <<Class ;
gotoxy(5,6) ;
cout <<"~~~~~~~~~~~~" ;
gotoxy(5,7) ;
cout <<"Tution Fee : " <<tution ;
gotoxy(5,8) ;
cout <<"P.T.A. Fee : " <<pta ;
gotoxy(5,9) ;

cout <<"Science Fee : " <<science ;


gotoxy(5,10) ;
cout <<"Pupil Fund : " <<pupil ;
gotoxy(5,11) ;
cout <<"S.U.P.W.
: " <<supw ;
break ;
}
}
file.close() ;

}
//**********************************************************
// FUNCTION TO MODIFY THE FEE RECORD FOR THE GIVEN DATA
//**********************************************************
void FEE :: MODIFY_RECORD(int tclass, float ttution, float tpta, float
tscience, float tpupil, float tsupw)
{
FEE fee;
fstream file ;
file.open("FEE.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while (!file.eof())
{
file.read((char *)&fee,sizeof(fee)) ;
if (file.eof())
break ;
if (tclass == Class)
{
Class
= tclass ;
tution = ttution ;
pta
= tpta ;
science = tscience ;
pupil
= tpupil ;
supw
= tsupw ;
temp.write((char *)&fee,sizeof(fee)) ;
}
else
temp.write((char *)&fee,sizeof(fee)) ;
}
file.close() ;
temp.close() ;
file.open("FEE.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while (!temp.eof())
{
temp.read((char *)&fee,sizeof(fee)) ;
if (temp.eof())
break ;
file.write((char *)&fee,sizeof(fee)) ;
}
file.close() ;
temp.close() ;
}
//**********************************************************

// FUNCTION TO GIVE DATA TO MODIFY THE FEE RECORD


//**********************************************************
void FEE :: MODIFICATION(void)
{
FEE fee;
clrscr() ;
char ch, t1[10] ;
int
valid=0, t=0, tclass=0 ;
float t2=0 ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Press <ENTER> for EXIT" ;
gotoxy(5,5) ; clreol() ;
cout <<"Enter Class for the Modification of the Fee
Structure : " ;
gets(t1) ;
t = atoi(t1) ;
tclass = t ;
if (strlen(t1) == 0)
return ;
if (tclass < 1 || tclass > 12)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
gotoxy(71,1) ;
cout <<"<0>=Exit" ;
DISPLAY(tclass) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,13) ; clreol() ;
cout <<"Do you want to modify the fee structure (y/n) : " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
float ttution=0.0, tpta=0.0, tscience=0.0, tpupil=0.0, tsupw=0.0 ;
gotoxy(5,13) ; clreol() ;
gotoxy(5,15) ;
cout <<"Tution Fee : " ;
gotoxy(5,16) ;
cout <<"P.T.A. Fee : " ;
gotoxy(5,17) ;
cout <<"Science Fee : " ;
gotoxy(5,18) ;
cout <<"Pupil Fund : " ;

gotoxy(5,19) ;
cout <<"S.U.P.W.
: " ;
int modified = 5 ;
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *)&fee,sizeof(fee)))
if (Class == tclass)
break ;
file.close() ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter Tution fee or Press <ENTER> for no change" ;
gotoxy(19,15) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
ttution = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
ttution = tution ;
gotoxy(19,15) ;
cout <<ttution ;
}
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter P.T.A. fee or Press <ENTER> for no change" ;
gotoxy(19,16) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tpta = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
tpta = pta ;
gotoxy(19,16) ;
cout <<tpta ;
}
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;

cout <<"Enter Science fee or Press <ENTER> for no change" ;


gotoxy(19,17) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tscience = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
tscience = science ;
gotoxy(19,17) ;
cout <<tscience ;
}
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter Pupil Fund or Press <ENTER> for no change" ;
gotoxy(19,18) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tpupil = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
} while (!valid) ;
if (strlen(t1) == 0)
{
modified-- ;
tpupil = pupil ;
gotoxy(19,18) ;
cout <<tpupil ;
}
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter S.U.P.W. fee or Press <ENTER> for no change" ;
gotoxy(19,19) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tsupw = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
} while (!valid) ;
if (strlen(t1) == 0)
{

modified-- ;
tsupw = supw ;
gotoxy(19,19) ;
cout <<tsupw ;
}
if (!modified)
return ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,21) ; clreol() ;
cout <<"Do you want to save (y/n) : " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
} while (ch != 'N' && ch != 'Y') ;
if (ch == 'N')
return ;
MODIFY_RECORD(tclass,ttution,tpta,tscience,tpupil,tsupw) ;
gotoxy(5,23) ;
cout <<"\7Record Modified" ;
gotoxy(5,25) ;
cout <<"Press any key to continue..." ;
getch() ;

}
//**********************************************************
// FUNCTION TO DISPLAY THE FEE SLIP FOR THE CLASS
//**********************************************************

void FEE :: FEE_SLIP(void)


{
FEE fee;
clrscr() ;
char ch, t1[10] ;
int
valid=0, t=0, tclass=0 ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Press <ENTER> for EXIT" ;
gotoxy(5,5) ; clreol() ;
cout <<"Enter Class to see the Fee Structure : " ;
gets(t1) ;
t = atoi(t1) ;
tclass = t ;
if (strlen(t1) == 0)
return ;
if (tclass < 1 || tclass > 12)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
char name[26] ;

do
{
gotoxy(5,25) ; clreol() ;
cout <<"ENTER NAME OF THE STUDENT" ;
valid = 1 ;
gotoxy(5,7) ; clreol() ;
cout <<"Name : " ;
gets(name) ;
} while (!valid) ;
clrscr() ;
gotoxy(28,3) ;
cout <<"ST. CECILIA'S PUBLIC SCHOOL" ;
gotoxy(22,6) ;
cout <<"NAME : " <<name ;
gotoxy(22,7) ;
cout <<"CLASS : " <<tclass ;
gotoxy(21,9) ;
cout <<"
PARTICULAR
AMOUNT" ;
gotoxy(25,21) ;
cout <<"TOTAL" ;
gotoxy(54,23) ;
cout <<"CASHIER" ;
fstream file ;
file.open("FEE.DAT", ios::in) ;
while (file.read((char *)&fee,sizeof(fee)))
if (Class == tclass)
break ;
file.close() ;
float total=0.0 ;
gotoxy(23,12) ;
cout <<"Tution fees
" <<tution ;
gotoxy(23,13) ;
cout <<"P.T.A. fees
" <<pta ;
gotoxy(23,14) ;
cout <<"Science fees
" <<science ;
gotoxy(23,15) ;
cout <<"Pupil fund
" <<pupil ;
gotoxy(23,16) ;
cout <<"S.U.P.W.
" <<supw ;
total = total+supw+pta+tution+science+pupil;
gotoxy(49,21) ;
cout<<total;
getch() ;

}
//**********************************************************
// MAIN FUNCTION TO CREATE MENU AND CALL OTHER FUNCTIONS
//**********************************************************
void main(void)
{
FEE fee ;
fee.ADDITION() ;
char ch ;
while (1)
{
clrscr() ;
gotoxy(33,8) ;

}
}

cprintf(" FEE ENQUIRY ") ;


gotoxy(35,11) ;
cprintf(" OPTIONS ") ;
gotoxy(35,14) ;
cout <<"1: FEE SLIP" ;
gotoxy(35,15) ;
cout <<"2: MODIFY" ;
gotoxy(35,16) ;
cout <<"3: LIST" ;
gotoxy(35,17) ;
cout <<"0: QUIT" ;
gotoxy(32,19) ;
cout <<"Enter your choice : " ;
ch = getche() ;
if (ch == 27 || ch == '0')
break ;
else
if (ch == '1')
fee.FEE_SLIP() ;
else
if (ch == '2')
fee.MODIFICATION() ;
else
if (ch == '3')
fee.LIST() ;

You might also like