Professional Documents
Culture Documents
New Microsoft Word Document
New Microsoft Word Document
//
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) ;
}
//**********************************************************
// 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() ;
}
//**********************************************************
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() ;
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
//**********************************************************
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) ;
}
}