Vous êtes sur la page 1sur 29

SUBMITTED AS A PART OF C.B.S.E.

CURRICULUM
FOR THE YEAR 2010-11
CONTENTS

CERTIFICATE

ACKNOWLEDGEMENT

PROJECT PREAMBLE

PROJECT STUDY

ALGORITHM

SOURCE CODE

OUTPUT
CERTIFICATE

This is to certify that

_______________,

Roll No. : ………………..

of Class XII D, S. D. Public School,

have worked on the project titled

Mobile Bill Management System

and have completed the project to my satisfaction.

Teacher’s Signature Student’s Signature


…………………….. ……………………...
ACKNOWLEDGEMENT
It gives me immense pleasure in expressing my
deep sense of gratitude to my respected teacher,
Ms. Vandana Gupta for her inspiring guidance
and thought in the preparation of the project.
This project would not have been completed
without her valuable guidance and her
tremendous effort.

I also extend my thanks to the Lab Asst. for extending


valuable help in making
the resources available.
PROJECT PREAMBLE
The project titled “Mobile Bill Management System”

has been developed as per the requirement of

CBSE for subject Computer Science (083) for

AISSCE – 2011. The source code has been

developed in C++. Compiler is Turbo C++.

The project deals with creation of records,

inserting data, deleting, searching and

printing of stored records. It also

includes validations.
PROJECT STUDY
CLASSES & FUNCTIONS USED IN THE PROJECT :
//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU
//**********************************************************

class MENU
{
public :
void main_menu(void) ;
private :
void edit_menu(void) ;
void edit_book(void) ;
void edit_member(void) ;
};

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO BOOKS
//**********************************************************

class BOOK
{
public :
void list(void) ;
char *bookname(int) ;
protected :
void add_new_book(int, char tname[33], char tauthor[26], float, int, int) ;
void update_copies(int, int, int) ;
void modify(int, char[], char[], float) ;
void deletion(void) ;
int book_found(int) ;
int bookname_found(char []) ;
int recordno(int) ;
int available(int) ;
char *authorname(int) ;
float bookprice(int) ;
int no_of_copies(int) ;
int bookcodeof(char[]) ;
void display(int) ;
int reccount(void) ;
void delete_rec(int) ;
private :
int bookcode, copies ;
char name[33], author[26] ;
float price ;
int avail ;

};
//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO MEMBERS
//**********************************************************

class MEMBER
{
public :
void list(void) ;
protected :
void add_mem(int, int, char [], char [], char[], int, int, int) ;
void modify(int, char[], char[], char[]) ;
void deletion(void) ;
int member_found(int) ;
void update_book(int, int, int, int, int) ;
char *membername(int) ;
char *memberphone(int) ;
char *memberaddress(int) ;
int recordno(int) ;
int lastcode(void) ;
int issued(int) ;
int fine(int) ;
void display(int) ;
void delete_rec(int) ;
private :
int memcode, bookcode ;
char name[26], phone[10], address[33] ;
int dd, mm, yy ; // DATE OF RETURNING THE BOOK //
};

//**********************************************************
// THIS IS DERIVED FROM CLASS BOOK & MEMBER AND CONTAINS
// FUNCTIONS FOR WORKING (ISSUE,RETURN,ETC).
//**********************************************************

class WORKING : public BOOK, public MEMBER


{
public :
void issuebook(void) ;
void returnbook(void) ;
void add_book(void) ;
void add_member(void) ;
void modify_book(void) ;
void modify_member(void) ;
void delete_book(void) ;
void delete_member(void) ;
};

//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED DATE & FINE
//**********************************************************

class DATE
{
public :
void extend_date(int,int,int,int) ;
int diff(int, int, int, int, int, int) ;
int day, mon, year ;
};
ALGORITHM
FOR INSERTING A RECORD TO A FILE:
 Open the file in append mode.
 Input the information for the record from the user.
 Using ‘write’ function available in file ‘fstream.h’ write the record on
the file.
 Close the file.

FOR DELETION OF A RECORD FROM A FILE:


 Open the master file i.e. the file that stores all the records, in read
mode.
 Open the transaction file i.e. a temporary file created for transaction,
in write mode.
 Input the information for the record to be deleted.
 Read the records from the master file till you reach the end of file.
Compare each record with the record to be deleted. If the two records
are found different, write the original record to the transaction file.
 Close both master as well as transaction file.
 Delete the master file using function ‘unlink’.
 Rename the transaction file as the master file.
FOR MODIFICATION OF A RECORD IN A FILE:
 Open the master file i.e. the file that stores all the records, in read
mode.
 Open the transaction file i.e. a temporary file created for transaction,
in write mode.
 Input the record to be modified from the user.
 Read the records from the master file till you reach the end of file.
Compare each record with the record to be modified. If the two
records are found different, write the original record to the transaction
file & if the records are same write the ‘new’ (updated) record to the
transaction file.
 Close both master as well as transaction file.
 Delete the master file using function ‘unlink’.
 Rename the transaction file as the master file.

FOR SEARCHING A RECORD IN A FILE:


 Open the file in read mode in which record is to be searched.
 Input the information required for comparing the distinct records.
 Start reading the records from the file till end of the file is not
encountered. Compare each record, if the record matches the display
the record, if value is not matched at last display ‘not found’.
 Close the file.
/*******************************************************************
*******************************************************************

MOBILE POST-PAID BILL MANAGEMENT SYSTEM

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

// HEADER FILES

#include<dos.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<fstream.h>

const char FNAME[] = "mobile.dat";

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

CLASS BILL

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

class mobile
{
private :
char name[30];
char add[50];
long int acno,dd,mm,yy;
char telno[11];
int monthrental;
int usagecharges;
int servicetax;
int netamt;

public :
int last_code(void);
void getdata();
void display();
void calc();
void putrecord();
void disrecord();
void disonerecord();
void delrecord();
void modify();
void generate();
void re_getdata();
};

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

FUNCTION TO FIND ACNO OF LAST RECORD

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

int mobile::last_code(void)
{
fstream file;
file.open(FNAME,ios::in | ios::binary);
file.seekg(0,ios::beg);
int count=0;
while (file.read((char*)this,sizeof(mobile)))
count=acno;
file.close();
return count;
}//end of function lastcode

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

FUNCTION TO INPUT DATA

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

void mobile :: getdata()


{
int t;
int valid;
t=last_code();
t=t+1;
acno=t;
gotoxy(25,4);
cout<<" ENTER DATA ";
gotoxy(25,5);
cout<<"~~~~~~~~~~~~~~";
gotoxy(5,7) ;
cout<<"ACCOUNT NO. IS :"<<acno;

do
{
valid=1;
gotoxy(5,9);
clreol();
cout<<"ENTER THE NAME:";
gotoxy(40,9);
clreol();
gets(name);
strupr(name);
if(strlen(name) < 1 || strlen(name) > 30)
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"\7 ENTER CORRECTLY(RANGE 1...30)";
getch();
}//end of if
} while(! valid); //end of do while

do
{
valid=1;
gotoxy(5,11);
clreol();
cout<<"ENTER ADDRESS:";
gotoxy(40,11);
clreol();
gets(add);
if (strlen(add) < 1||strlen(add) > 30)
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"ENTER CORECTLY(RANGE:1...30)";
getch();
}// end of if
} while(!valid); //end of do while

do
{
valid=1;
gotoxy(5,13);
clreol();
cout<<"ENTER PHONE NUMBER:";
gotoxy(40,13);
clreol();
gets(telno);
if((strlen(telno)<10 && strlen(telno)>0 || (strlen(telno)>10)))
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"ENTER CORRECTLY";
getch();
}//end of if
} while(!valid); //end of do while

do
{
valid=1;
gotoxy(5,15);
clreol();
cout<<"ENTER MONTHLY RENTAL:";
gotoxy(40,15);
clreol();
cin>>monthrental;
if( monthrental<=0)
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"ENTER CORRECTLY";
getch();
}//end of if
} while(!valid); //end of do while

usagecharges=0;
servicetax=0;
netamt=0;
dd=0,mm=0,yy=0;
gotoxy(30,40);
cout<<"Thank you"<<endl;
cout<<"press any key to continue...";
getch();
}

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

FUNCTION TO CALCULATE BILL

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

void mobile :: calc()


{
servicetax=.1236*(monthrental+usagecharges);
netamt=monthrental+usagecharges+servicetax;
}

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

FUNCTION TO DISPLAY DATA

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

void mobile :: display()


{
gotoxy(32,3) ;
cprintf(" BILL ") ;
gotoxy(23,5);
cout<<"BILL Date :"<<dd<<"-"<<mm<<"-"<<yy;
gotoxy(23,10) ;
cout<<"Name :"<<name;
gotoxy(23,11) ;
cout<<"Address :"<<add;
gotoxy(23,12);
cout<<"Mobile No. :"<<telno;
gotoxy(23,13);
cout<<"Acc.no :"<<acno;
gotoxy(23,14) ;
cout<<"Monthly Rental :"<<monthrental;
gotoxy(23,15) ;
cout<<"Usage Charges :"<<usagecharges;
gotoxy(23,16) ;
cout<<"Service Tax(12.36%):"<<servicetax;
gotoxy(23,17) ;
cout<<"Total Charges :Rs."<<netamt;

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

FUNCTION TO PUT A RECORD IN A FILE

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

void mobile :: putrecord()


{
fstream a;
a.open(FNAME,ios::out | ios::app | ios::binary);
getdata();
a.write((char*) this, sizeof(mobile));
a.close();
clrscr();
display();
gotoxy(27,19);
cout<<"Press any key yo continue...";
getch();
}

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

FUNCTION TO READ FROM A FILE

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

void mobile :: disrecord()


{
fstream f;
int count=1;
f.open(FNAME,ios::in | ios::out | ios::binary);
while(1)
{
f.read((char*)this,sizeof(mobile));
if(f.eof())
{
gotoxy(33,12);
cout<<"No More Records";
gotoxy(27,18);
cout<<"Press any key to continue...";
getch();
break;
}
gotoxy(36,8);
cout<<"Record No:"<<count;
display();
gotoxy(20,18);
cout<<"Press any key for next record.......";
getch();
count++;
clrscr();
}
f.close();
}

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

FUNCTION TO DELETE A RECORD

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

void mobile :: delrecord()


{
int count,flag;
char tno[11];
int valid;
gotoxy(32,3);
cprintf(" DELETE A RECORD ");
gotoxy(32,12);
do
{
valid=1;
gotoxy(5,13);
clreol();
cout<<"ENTER PHONE NUMBER:";
gotoxy(40,13);
clreol();
gets(tno);
cout<<tno;
if((strlen(tno)<10 && strlen(tno)>0 || (strlen(tno)>10)))
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"ENTER CORRECTLY";
getch();
}//end of if
} while(!valid); //end of do while
fstream f,n;
f.open(FNAME,ios::out | ios::in | ios::app | ios::binary);
f.seekg(0);
n.open("new.txt",ios::out | ios::trunc | ios::binary);
f.read((char*)this,sizeof(mobile));
while(f)
{
if (strcmp(telno,tno)==0)
{
flag=1;
clrscr();
display();
gotoxy(32,7);
cprintf(" RECORD TO DELETE ");

}
else
n.write((char*)this,sizeof(mobile));
f.read((char*)this,sizeof(mobile));
}
f.close();
n.close();
if (flag==1)
{ remove(FNAME);
rename("new.txt",FNAME);
}
else
cout<<"matching record not found\n";
gotoxy(27,19);
cout<<"Press any key to continue...";
getch();
}

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

FUNCTION TO DISPLAY ONE RECORD BY MOBILE NUMBER

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

void mobile :: disonerecord()


{
int flag;
int valid;
char tno[11];
gotoxy(32,7);
cprintf(" DISPLAY A RECORD ");
gotoxy(30,12);
do
{
valid=1;
gotoxy(5,13);
clreol();
cout<<"ENTER PHONE NUMBER:";
gotoxy(40,13);
clreol();
gets(tno);
cout<<tno;
if((strlen(tno)<10 && strlen(tno)>0 || (strlen(tno)>10)))
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"ENTER CORRECTLY";
getch();
}//end of if
} while(!valid); //end of do while

fstream f;
flag=0;
f.open(FNAME,ios::in | ios::binary);
f.read((char*)this,sizeof(mobile));
while(f)
{
if(strcmp(telno,tno)==0)
{
clrscr();
flag=1;
display();
break;
}

f.read((char*)this,sizeof(mobile));
}
f.close();
if(flag==0)
{
gotoxy(32,16);
cout<<"Record not found";
}
gotoxy(20,18);
cout<<"Press any key to continue............";
getch();
}

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

FUNCTION TO MODIFY A RECORD

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

void mobile :: modify()


{
int flag,recordno,loc,valid;
char newadd[40];
char tno[11];
flag=0;
recordno=0;
gotoxy(32,7);
cprintf(" MODIFY A RECORD ");
gotoxy(30,12);
do
{
valid=1;
gotoxy(5,13);
clreol();
cout<<"ENTER PHONE NUMBER:";
gotoxy(40,13);
clreol();
gets(tno);
cout<<tno;
if((strlen(tno)<10 && strlen(tno)>0 || (strlen(tno)>10)))
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"ENTER CORRECTLY";
getch();
}//end of if
} while(!valid); //end of do while
fstream f,n;
f.open(FNAME,ios::out | ios::in | ios::app |ios::binary);
while(1)
{
f.read((char*)this,sizeof(mobile));
if(f.eof())
break;
if(strcmp(telno,tno)==0)
{
clrscr();
flag=1;
display();
gotoxy(32,7);
cprintf(" RECORD TO MODIFY ");
break;
}
recordno++;
}
f.close();
if(flag==0)
{
gotoxy(32,16);
cout<<"Record not found";
gotoxy(22,19);
cout<<"Press any key to continue...............";
getch();
return;
}
gotoxy(22,18);
cout<<"You can only modify the address";
gotoxy(20,19);
cout<<"Press any key to continue...............";
getch();
clrscr();
gotoxy(32,7);
cprintf(" ENTER NEW DATA ");
f.open(FNAME, ios::out | ios::ate);
gotoxy(22,13);
cout<<"Enter new address :";
gets(newadd);
strcpy(add,newadd);
loc = (recordno) * sizeof(mobile);
f.seekp(loc);
f.write((char*) this, sizeof(mobile));
f.close();
gotoxy(30,17);
cout<<"Record Modified ";
gotoxy(20,19);
cout<<"Press any key to continue...............";
getch();
}

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

FUNCTION TO GENERATE BILL

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

void mobile :: generate()


{
int ucharges;
struct date d;
int valid;
char tno[11];
int d1, m1, y1 ;
getdate(&d);
d1 = d.da_day ;
m1 = d.da_mon ;
y1 = d.da_year ;
int flag=0,loc,recordno=0;
gotoxy(32,7);
cprintf(" GENERATE BILL ");
gotoxy(30,12);
do
{
valid=1;
gotoxy(5,13);
clreol();
cout<<"ENTER PHONE NUMBER:";
gotoxy(40,13);
clreol();
gets(tno);
cout<<tno;
if((strlen(tno)<10 && strlen(tno)>0 || (strlen(tno)>10)))
{
valid=0;
gotoxy(5,25);
clreol();
cout<<"ENTER CORRECTLY";
getch();
}//end of if
} while(!valid); //end of do while
fstream f,a;
f.open(FNAME,ios::in | ios::out | ios::binary);
while(1)
{
f.read((char*)this,sizeof(mobile));
if(f.eof())
break;
if(strcmp(telno,tno)==0)
{
flag=1;
break;
}
recordno++;
}
if(flag==0)
{
gotoxy(32,16);
cout<<"Record not found";
gotoxy(22,19);
cout<<"Press any key to continue...........";
getch();
return;
}
f.close();
if(flag==1)
{
a.open(FNAME, ios::out | ios::ate);
gotoxy(30,14);
cout<<"Enter usage charges :";
cin>>ucharges;
usagecharges=ucharges;
dd=d1;
mm=m1;
yy=y1;
calc();
loc = (recordno) * sizeof(mobile);
a.seekp(loc);
a.write((char*)this, sizeof(mobile));
clrscr();
display();
a.close();
gotoxy(20,19);
cout<<"Press any key to continue..........";
}
getch();
}

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

VOID MAIN

***************************************************************************/
void main()
{
clrscr();
mobile e;
int ch;
char ans;
long int pass;
while (1)
{
clrscr();
gotoxy(32,8);
cprintf(" MOBILE BILL ");

gotoxy(35,10);
cprintf(" OPTIONS ");
gotoxy(28,12);
cout <<"1: INSERT NEW USER";

gotoxy(28,14);
cout <<"2: DISPLAY RECORD OF A USER";

gotoxy(28,16);
cout <<"3: DISPLAY ALL RECORDS";

gotoxy(28,18);
cout <<"4: DELETE A RECORD";

gotoxy(28,20);
cout <<"5: MODIFY A RECORD";

gotoxy(28,22);
cout <<"6: GENERATE BILL";

gotoxy(28,26);
cout <<"0: QUIT";

gotoxy(28,28);
cout <<"ENTER YOUR CHOICE: ";
char ch=getche();
if (ch == 27)
break;

else
if (ch == '1')
{
clrscr();
e.putrecord();
}

else
if (ch == '2')
{
clrscr();
e.disonerecord();
}

else
if (ch == '3')
{
clrscr();
e.disrecord();
}

else
if(ch == '4')
{
clrscr();
e.delrecord();
}

else
if( ch == '5')
{
clrscr();
e.modify();
}

else
if( ch == '6')
{
clrscr();
e.generate();
}

if( ch == '0')
break;

}
}
MOBILE BILL MANAGEMENT SYSTEM

OPTIONS

1: INSERT NEW USER

2: DISPLAY RECORD OF A USER

3: DISPLAY ALL RECORDS

4: DELETE A RECORD

5: MODIFY A RECORD

6: GENERATE BILL

0: QUIT

ENTER YOUR CHOICE: 1

ENTER DATA
~~~~~~~~~~~~~~
ACCOUNT NO. IS : 1
ENTER THE NAME: NITIN
ENTER ADDRESS: WZ-38 ROHINI NEW DELHI
ENTER PHONE NUMBER: 9810023100
ENTER MONTHLY RENTAL: 250

Thank you
press any key to continue...

Name : NITIN
Address :WZ-38 ROHINI NEW DELHI
Mobile No. :9810023100
Acc.no :1
Monthly Rental :250
Usage Charges :0
Service Tax(12.36%) :0
Total Charges :Rs.0

Press any key to continue...


DISPLAY A RECORD
ENTER PHONE NUMBER: 9810023100

Name : NITIN
Address :WZ-38 ROHINI NEW DELHI
Mobile No. :9810023100
Acc.no :1
Monthly Rental :250
Usage Charges :0
Service Tax(12.36%) :0
Total Charges :Rs.0

Record No:1
Name : NITIN
Address :WZ-38 ROHINI NEW DELHI
Mobile No. :9810023100
Acc.no :1
Monthly Rental :250
Usage Charges :0
Service Tax(12.36%) :0
Total Charges :Rs.0

Press any key for next record.......

DELETE A RECORD
󰀡

ENTER PHONE NUMBER: 1234567890


Record not found

RECORD TO MODIFY

ENTER PHONE NUMBER: 1234567890

Name : NITIN
Address :WZ-38 ROHINI NEW DELHI
Mobile No. :9810023100
Acc.no :1
Monthly Rental :250
Usage Charges :0
Service Tax(12.36%) :0
Total Charges :Rs.0

You can only modify the address


Press any key to continue...............

ENTER NEW DATA

Enter new address :RZ-90 ROHINI NEW DELHI


Record Modified
Press any key to continue...............

GENERATE BILL

ENTER PHONE NUMBER: 9810023100


Enter usage charges : 250

BILL
BILL Date :29-10-2007
Name :NITIN
Address : RZ-90 ROHINI NEW DELHI
Mobile No. :9810023100
Acc.no :1
Monthly Rental :250
Usage Charges :250
Service Tax(12.36%) :61
Total Charges :Rs.561

Press any key to continue..........

Vous aimerez peut-être aussi