This project is based on File Handling . An innovative project on petrol pump management , deals with basic function in a petrol pump .
Do like , share and comment if my work helped you ;)
2. CERTIFICATE
This is to certified that the project has been satisfactorily performed by Master
RUSHIL AGGARWAL studying in NAVY CHILDREN SCHOOL of class XII-A under the
guidance of Mrs. Smera Girish during the academic year 2015-2016.
Signature of Head Of Department Signature of External Examiner
School Stamp
3. Acknowledgement
I would like to express my sincere gratitude to my
computer science Teacher Mrs. Smera Girish for their
vital support guidance and encouragement without
which this project would not have come forth from my
side.
I would like to express my heartily gratitude to the lab
incharge , Mr. Vaibhav for his support during the making
of this project .
I would like to thank my parents and friends who have
helped me with their valuable suggestions and guidance
has been helpful in various phases of the completion of
the project.
5. AIM
TO CREATE A C++ PROGRAM FOR
PETROL PUMP MANAGEMENT SYSTEM
6. INTRODUCTION
This program is mainly intended for the various
activities that are carried out at the petrol pump and
service station. In this project we included about how
we can find out the information about the various
operations carried out at a petrol pump.
The program is sub-divided into 4 domains listed below
Add new record
Display all record
Find a record
Exit
9. CODING
//password is 'OIL BARON'
#include<ctype.h>
#include<string.h>
#include<stdio.h>
#include<dos.h>
#include<iomanip.h>
#include<iostream.h>
#include<fstream.h>
#include<process.h>
#include<conio.h>
class pump
{ private :
float totpet,tsalepet,charg,qty;
int totservice,tottyer,sno,pak;
float totdis,tsaledis,tlubric,ratepetrol,ratedisel;
float tsalelubric,tsalelubricpak,tsaleservice,tsaletyer,tlubricpak;
char no[15],item[10];
public:
void end();
void sale(float,float,float,float,float,float);
void stock(float,float,float,int,int,int);
void start();
int service();
void entry(float,float,char*);
int tyers();
void show();
void bill();
void find();
void getdata(char*,int,char *,float,float);
void bill(char
*,float,float,float,float,float,float,int,float,int,float,float);
void password();
}petrol;
void delay(unsigned long time);
void boder(char x);
///////////////////////////////////////////////////////////////////////////////
// MAIN FUNCTION //
///////////////////////////////////////////////////////////////////////////////
void main()
{
clrscr();
char no[15],item[10];
float ratepetrol,ratedisel,ratelub,costlub=0,lub=0,costpak;
float
costservice=0,costtyer=0,litpet=0,costpet=0,litdis=0,costdis=0;
int m=1,d,x=0,sno,choice,choicepet,choicedis,choicelubric;
int pak=0,totservice=0,tottyer=0;
10. float
totpet=0,tsalepet=0,totdis=0,tsaledis=0,tlubric=0,tsalelubric=0;
float tlubricpak=0,tsalelubricpak=0,tsaleservice=0,tsaletyer=0;
float charg,rs_pk=0,qty;
petrol.start(); //The Welcome screen
clrscr();
petrol.password(); //For Password
boder('#'); //For Border
gotoxy(25,10);
cout<<"Enter the rate of Petrol :: ";
cin>>ratepetrol;
gotoxy(25,13);
cout<<"Enter the rate of Diesel :: ";
cin>>ratedisel;
while(m<4)
{
clrscr();
boder('^');
gotoxy(25,8);
cout<<"Enter [ 1 ] for Add New Record ";
gotoxy(25,10);
cout<<"Enter [ 2 ] for Display All Records ";
gotoxy(25,12);
cout<<"Enter [ 3 ] for Find Any Record ";
gotoxy(25,14);
cout<<"Enter [ 4 ] for Exit ";
gotoxy(25,18);
cout<<"Enter Your Choice Here :: ";
cin>>m;
clrscr();
if(m==1) // TO ADD NEW RECORD
{
d=2;
fstream fill;
fill.open("petfile.dat",ios::app);
int i,j,k;
fill.seekg(0,ios::end);
i=fill.tellg();
j=sizeof(pump);
k=i/j;
j++;
sno=k+1;
gotoxy(10,3);
11. cout<<"N E W V E H I C L E ";
gotoxy(10,4);
cout<<"---------------------";
gotoxy(10,5);
cout<<"Service Number :: ";
cout<<sno;
gotoxy(10,7);
vno:
gotoxy(3,8);
cout<<"Please enter vehicle number in this format
[hr03c1234] only :: ";
gets(no);
if(strlen(no)==0)
{
gotoxy(10,12);
cout<<"Vehicle Number cannot left blank";
gotoxy(10,14);
cout<<"Enter Vehicle Number please....";
getch();
gotoxy(10,12);
clreol();
gotoxy(10,14);
clreol();
goto vno;
}
for(int r=0;no[r]!='0';r++) //loop to change name to uppercase
{
no[r]=toupper(no[r]);
}
litpet=costpet=litdis=costdis=lub=costlub=pak=rs_pk=x=costservice=costtyer=0;
while(d>1) //For exit control
{ clrscr();
petrol. entry(ratepetrol,ratedisel,no);
cin>>choice;
switch(choice)
{
case 1: //For Petrol entry
clrscr();
gotoxy(33,2);
strcpy(item,"Petrol");
cout<<"PETROL";
gotoxy(33,3);
12. cout<<"------nn";
gotoxy(10,5);
cout<<"Enter [ 1 ] for Litern ";
gotoxy(10,6);
cout<<"Enter [ 2 ] for Rupees ";
gotoxy(10,7);
cout<<"Enter Your Choice (1 or 2) :: ";
cin>>choicepet;
if(choicepet==1) //For entry in Liters(petrol)
{
gotoxy(10,10);
cout<<" How many liters :: ";
cin>>litpet;
totpet=totpet+litpet;
qty=litpet;
costpet=litpet*ratepetrol;
charg=costpet;
tsalepet=tsalepet+costpet;
gotoxy(10,12);
cout<<" Rupees. ";
cout.setf(ios::fixed);
cout<<setprecision(3)<<costpet<<" only ";
gotoxy(50,23);
cout<<"Press Enter key ";
getch();
}
if(choicepet==2) //For entry in Rupees(petrol)
{
gotoxy(10,10);
cout<<" How much Rupees :: ";
cin>>costpet;
charg=costpet;
tsalepet=tsalepet+costpet;
qty=costpet/ratepetrol;
litpet=qty;
totpet=totpet+qty;
gotoxy(10,12);
cout.setf(ios::fixed);
cout<<" Petrol filled "<<setprecision(2)<<qty<<"
liters";
gotoxy(50,23);
cout<<"Press Enter key ";
getch();
}
break;
case 2: //For Diesel entry
clrscr();
13. strcpy(item,"Diesel");
gotoxy(33,2);
cout<<"DIESEL";
gotoxy(33,3);
cout<<"------";
gotoxy(10,5);
cout<<"Enter [ 1 ] for Litern ";
gotoxy(10,6);
cout<<"Enter [ 2 ] for Rupees ";
gotoxy(10,7);
cout<<" n Enter your choice (1 or 2 ) :: ";
cin>>choicedis;
if(choicedis==1) //For entry in Liters(diesel)
{
gotoxy(10,10);
cout<<"How many liters :: ";
cin>>litdis;
totdis=totdis+litdis;
qty=litdis;
costdis =litdis*ratedisel;
charg=costdis;
tsaledis=tsaledis+costdis;
gotoxy(10,12);
cout.setf(ios::fixed);
cout<<"Rupees :"<<setprecision(2)<<costdis<<" only.";
gotoxy(50,23);
cout<<"Press Enter key ";
getch();
}
if(choicedis==2) //For entry in Rupees(diesel)
{
gotoxy(10,10);
cout<<" How much Rupees :: ";
cin>>costdis;
tsaledis=tsaledis+costdis;
charg=costdis;
qty=costdis/ratedisel;
litdis=qty;
totdis=totdis+qty;
gotoxy(10,12);
cout.setf(ios::fixed);
cout<<"Diesel filled = "<<setprecision(3)<<qty<<" liters ";
gotoxy(50,23);
cout<<"Press Enter key ";
14. getch();
}
break;
case 3: //Entry for Tyers and tube
clrscr();
strcpy(item,"Tyers");
charg=petrol.tyers();
costtyer=charg;
tottyer++;
tsaletyer=tsaletyer+charg;
gotoxy(50,23);
cout<<"Press Enter key ";
getch();
break;
case 4: //Entry for services
clrscr();
x++;
strcpy(item,"Service");
charg=petrol.service();
qty=0;
costservice=charg;
tsaleservice=charg+tsaleservice;
totservice++;
gotoxy(50,23);
cout<<"Press Enter key ";
getch();
break;
case 5: //Entry for lubricants
clrscr();
strcpy(item,"Lubricant");
gotoxy(33,2);
cout<<"LUBRICANTS";
gotoxy(33,3);
cout<<"----------";
gotoxy(10,5);
cout<<"Enter [ 1 ] for liter ";
gotoxy(10,6);
cout<<"Enter [ 2 ] for Packets";
gotoxy(10,7);
cout<<"Enter Your choice :: ";
cin>>choicelubric;
switch(choicelubric)
{
15. case 1: //Entry for 'in liters'
gotoxy(10,9);
cout<<"Rate of the oil ::";
cin>>ratelub;
gotoxy(10,10);
cout<<"How many liters :: ";
cin>>lub;
qty=lub;
tlubric=lub+tlubric;
charg=ratelub*lub;
costlub=charg;
tsalelubric=tsalelubric+charg;
gotoxy(10,13);
cout<<"The charges for ";
cout<< lub;
cout<<" liters oil :: ";
cout.setf(ios::fixed);
cout<<setprecision(3)<<charg<<" Rupees only.";
gotoxy(50,23);
cout<<"Press Enter key ";
getch();
break;
case 2: //Entry for 'in Rupees'
gotoxy(10,9);
cout<<"Enter the rate of one packet :: ";
cin>>costpak;
gotoxy(10,10);
cout<<"Enter how many packets you want to buy :: ";
cin>>pak;
qty=pak;
tlubricpak=tlubricpak+pak;
charg=pak*costpak;
rs_pk=charg;
tsalelubricpak=tsalelubricpak+charg;
gotoxy(10,13);
cout<<"The charges for the ";
cout<< pak;
cout<<" packets :: ";
cout.setf(ios::fixed);
cout<<setprecision(3)<<rs_pk<<" Rupees only";
gotoxy(50,23);
cout<<"Press Enter key ";
getch();
break;
}
break;
16. case 6: //for reveiw for the record(bill)
clrscr();
petrol.bill(no,litpet,costpet,litdis,costdis,lub,costlub,pak,rs_pk,x,
costservice,costtyer);
getch();
break;
case 7:
d=0; //for exit from entry record
break;
}
petrol.getdata(no,sno,item,qty,charg);
fill.write((char*)&petrol,sizeof(petrol));
fill.close();
}
}
if(m==2) //for displaying all records(in file)
{
clrscr();
petrol.show();
}
//for finding a record(in file)
if(m==3)
{
clrscr();
petrol.find();
getch();
}
if(m==4) //for exit from entry record
break;
}
petrol.sale(tsalepet,tsaledis,tsalelubric,tsalelubricpak,tsaleservice,tsaletyer
); // for day's sale
petrol.stock(totpet,totdis,tlubric,tlubricpak,totservice,tottyer);
//for day's stock usage
petrol.end();
} //for end display
17. //:::::::::::::::::::::::| functions |:::::::::::::::::::::::::::::://
/* ---------------- Function to display Start ---------------------------- */
void pump::start()
{
char a[10][42];
strcpy(a[1],"A P R O G R A M D E V L O P E D ");
strcpy(a[2],"F O R");
strcpy(a[3]," ");
strcpy(a[4],"P E T R O L P U M P M A N A G E M E N T");
strcpy(a[5]," ");
strcpy(a[6]," M A D E B Y");
strcpy(a[7],"R U S H I L A G G A R W A L , XII-A");
strcpy(a[8]," ");
int r=4;
for(int j=1;j<=8;j++)
{
int l=strlen(a[j]);
int x=((80-l)/2)+1;
gotoxy(x,r);
for(int p=0;p<l;p++)
{
putch(a[j][p]);
delay(1000);
}
delay(600);
r=r+2;
if(j==5)
r=r+2;
}
gotoxy(13,24);
cout<<"WAIT FOR MOMENT...";
delay(80000);
}
///////////////////////////////////////////////////////////////////////////////
///////
/* ---------------- Function to display Entry Menu --------------------------
-- */
void pump::entry(float x,float y,char *xx)
{
gotoxy(37,1);
cout<<"MENU";
18. gotoxy(36,2);
cout<<"------";
gotoxy(27,3);
cout<<"VEHICLE NUMBER :: ";
cout<<xx;
gotoxy(10,5);
cout<<"RATE OF PETROL :: Rs ";
cout.setf(ios::fixed);
cout<<setprecision(2)<<x;
gotoxy(45,5);
cout<<"RATE OF DIESEL :: Rs ";
cout<<setprecision(2)<<y;
gotoxy(30,8);
cout<<"ENTER [ 1 ] FOR PETROL ";
gotoxy(30,10);
cout<<"ENTER [ 2 ] FOR DIESEL ";
gotoxy(30,12);
cout<<"ENTER [ 3 ] FOR TYERS ";
gotoxy(30,14);
cout<<"ENTER [ 4 ] FOR SERVICE ";
gotoxy(30,16);
cout<<"ENTER [ 5 ] FOR LUCBRICANTS ";
gotoxy(30,18);
cout<<"ENTER [ 6 ] FOR DISPLAY CURRENT RECORD ";
gotoxy(30,20);
cout<<"ENTER [ 7 ] FOR EXIT FROM CURRENT RECORD ";
gotoxy(30,24);
cout<<"Enter Your choice :: ";
}
///////////////////////////////////////////////////////////////////////////////
///////
/* ---------------- Function to charge services ----------------------------
*/
int pump::service()
{
int ch,ch1,charg;
clrscr();
gotoxy(37,3);
cout<<"SERVICES";
gotoxy(37,4);
19. cout<<"--------";
gotoxy(10,6);
cout<<"Enter [ 1 ] For Washing ";
gotoxy(10,7);
cout<<"Enter [ 2 ] For Internal Cleaning ";
gotoxy(10,8);
cout<<"Enter [ 3 ] For Washing and Polishing ";
gotoxy(10,10);
cout<<"Enter Your choice (1 or 2 or 3) :: ";
cin>>ch;
clrscr();
switch(ch)
{
case 1:
gotoxy(10,7);
cout<<"Enter [ 1 ] For Two Wheeler ";
gotoxy(10,8);
cout<<"Enter [ 2 ] For Four Wheeler ";
gotoxy(10,10);
cout<<"Enter Your choice (1 or 2) :: ";
cin>>ch1;
if(ch1==1)
charg=50;
else
charg=90;
gotoxy(10,13);
cout<<"Washing Charges :: Rs ";
cout<<charg;
break;
case 2:
charg=180;
gotoxy(10,13);
cout<<"Inner Cleaning Charges :: Rs ";
cout<<charg;
break;
case 3:
gotoxy(10,7);
cout<<"Enter [ 1 ] For Two Wheeler n";
gotoxy(10,9);
cout<<"Enter [ 2 ] For Four Wheelern";
gotoxy(10,11);
cout<<"Enter Your Choice (1 or 2) :: ";
cin>>ch1;
if(ch1==1)
charg=60;
22. cout<<setprecision(2)<<tsaledis;
gotoxy(12,12);
cout<<"LUBRICANT 1) LITERS";
gotoxy(62,12);
cout<<setprecision(2)<<tsalelubric;
gotoxy(21,13);
cout<<" 2) PACKETS ";
gotoxy(62,13);
cout<<setprecision(2)<<tsalelubricpak;
gotoxy(12,15);
cout<<"VEHICLES SERVICE";
gotoxy(62,15);
cout<<setprecision(2)<<tsaleservice;
gotoxy(12,17);
cout<<"TYERS";
gotoxy(62,17);
cout<<setprecision(2)<<tsaletyer;
gotoxy(10,19);
cout<<"--------------------------------------------------------";
gotoxy(51,21);
cout<<"CASH : ";
cout<<setprecision(2)<<sale;
gotoxy(50,22);
cout<<"-----";
gotoxy(60,24);
cout<<"press any key...";
getch();
}
///////////////////////////////////////////////////////////////////////////////
///////
/* ---------------- Function to display End ---------------------------- */
void pump::end()
{
clrscr();
boder('#');
gotoxy(26,8);
cout<<"T H A N K S F O R U S I N G";
gotoxy(36,10);
cout<<"T H I S";
23. gotoxy(30,12);
cout<<"P R O G R A M";
gotoxy(58,18);
cout<<"NAME- RUSHIL AGGARWAL";
gotoxy(58,20);
cout<<"CLASS- XII A";
gotoxy(58,22);
cout<<"ROLL No.- 13";
gotoxy(8,22);
cout<<"Press any key to exit ...";
getch();
}
///////////////////////////////////////////////////////////////////////////////
///////
/* ---------------- Function for tyer/tube purchase -------------------------
--- */
int pump::tyers()
{ int ty,choice,tb;
float rt,amount,amount1,rtb,charg;
gotoxy(5,3);
cout<<"Enter [ 1 ] For New Tyre ";
gotoxy(5,4);
cout<<"Enter [ 2 ] For Tube ";
gotoxy(5,5);
cout<<"Enter [ 3 ] For Tyre and Tube " ;
gotoxy(5,7);
cout<<"Enter your choice (1 or 2 or 3) :: ";
cin>>choice;
switch(choice)
{
case 1: //for tyers only
clrscr();
gotoxy(5,3);
cout<<"Enter no of tyers you want to buy :: ";
cin>>ty;
gotoxy(5,4);
cout<<"Cost per tyre :: Rs ";
cin>>rt;
amount=ty*rt;
gotoxy(5,6);
cout<<"The cost of ";
24. cout<<ty;
cout<<" tyers is :: Rs ";
cout.setf(ios::fixed);
cout<<setprecision(2)<<amount;
break;
case 2: //for tubes only
clrscr();
gotoxy(5,3);
cout<<"How many tubes want to buy :: ";
cin>>tb;
gotoxy(5,4);
cout<<"Cost per tube :: Rs ";
cin>>rtb;
amount=tb*rtb;
gotoxy(5,6);
cout<<"The cost of ";
cout<< tb;
cout<<" tube is :: Rs ";
cout.setf(ios::fixed);
cout<<setprecision(2)<<amount;
break;
case 3: //for tyers and tubes both
clrscr();
gotoxy(5,3);
cout<<"Enter no of tyers you want to buy :: ";
cin>>ty;
gotoxy(5,4);
cout<<"Cost of one tyre :: Rs ";
cin>>rt;
amount1=ty*rt;
gotoxy(5,5);
cout<<"The cost of ";
cout<<ty;
cout<<" tyers is :: Rs ";
cout.setf(ios::fixed);
cout<<setprecision(2)<<amount1;
gotoxy(5,7);
cout<<"How many tubes want to buy :: ";
cin>>tb;
gotoxy(5,8);
cout<<"Cost per tube :: Rs ";
cin>>rtb;
charg=tb*rtb;
gotoxy(5,9);
cout<<"The cost of ";
cout<<tb;
25. cout<<" tubes is :: Rs ";
cout<<setprecision(2)<<charg;
amount=charg+amount1;
gotoxy(5,12);
cout<<"Total charges for ";
cout<<ty;
cout<<" tyer and ";
cout<<tb;
cout<<"tube :: Rs ";
cout<<setprecision(2)<<amount;
break;
} return(amount);
}
///////////////////////////////////////////////////////////////////////////////
///////
/* ---------------- Function to find a record in file -----------------------
----- */
void pump::find()
{
char no1[15]; int y=0;
fstream file;
clrscr();
file.open("petfile.dat",ios::in|ios::out);
file.seekg(0,ios::beg);
clrscr();
gotoxy(4,6);
cout<<"ENTER VEHICLE NUMBER :: # ";
gets(no1);
for(int p=0;no1[p]!='0';p++)
{
no1[p]=toupper(no1[p]);
}
file.read((char*)&petrol,sizeof(petrol));
while(!file.eof())
{ if(strcmp(no1,no)==0)
{ y=8;
clrscr();
gotoxy(16,10);
cout<<"The record number is :: ";
cout<<sno;
gotoxy(16,12);
cout<<"Work done ";
cout<<item;
gotoxy(16,14);
26. cout<<"Charges ";
cout.setf(ios::fixed);
cout<<setprecision(2)<<charg;
getch();
}
file.read((char*)&petrol,sizeof(petrol));
}
file.close();
if(y==0)
{
gotoxy(30,12);
cout<<"No entry of this number ";
}
}
///////////////////////////////////////////////////////////////////////////////
///////
/* ---------------- Function to Display from a file -------------------------
--- */
void pump::show()
{
clrscr();
fstream file;
file.open("petfile.dat",ios::in,ios::out);
file.seekg(0,ios::beg);
int row = 3;
int flag = 0;
char ch;
gotoxy(1,1);
cout<<"S NO. VEHICLE NUMBER WORK DONE QTY
CHARGES";
gotoxy(1,2);
cout<<"-----------------------------------------------------------
----------------------";
while(file.read((char*)&petrol,sizeof(petrol)) )
{
flag = 0;
delay(1000);
gotoxy(3,row);
cout<<sno;
gotoxy(8,row);
cout<<no;
gotoxy(33,row);
cout<<item;
gotoxy(50,row);
cout.setf(ios::fixed);
cout<<setprecision(2)<<qty;
27. gotoxy(71,row);
cout<<setprecision(2)<<charg;
if( row == 23 )
{
flag = 1;
row = 3;
gotoxy(17,25);
cout<<"Press any key to go back to MAIN MENU....";
ch = getch();
if( ch == 27 )
break;
clrscr();
gotoxy(1,1);
cout<<"S NO. VEHICLE NUMBER WORK DONE QTY CHARGES ";
cout<<"------------------------------------------";
}
else
row = row + 2;
}
if(!flag)
{
gotoxy(20,25);
cout<<"Press any key to go back to MAIN MENU....";
getch();
}
file.close();
}
///////////////////////////////////////////////////////////////////////////////
/* ---------------- Function to assign values(s.number,quantity,charges) -----
----------- */
void pump:: getdata(char* no2,int sno1,char *item1,float qty1,float charg1)
{
strcpy(no,no2);
sno=sno1;
strcpy(item,item1);
qty=qty1;
charg=charg1;
}
///////////////////////////////////////////////////////////////////////////////
/* ---------------- Function to display Bill ---------------------------- */
void pump::bill(char *no,float litpet,float cpet,float litdis,float cdis,float
lubric,float clubric,int pak,float cpak,int service,float cservice,float ctyer)
{
clrscr();
float sale=0;
sale=cpet+cdis+clubric+cpak+cservice+ctyer;
gotoxy(27,1);
30. }
///////////////////////////////////////////////////////////////////////////////
///////
/* ---------------- Function for a pause ---------------------------- */
void delay (unsigned long time )
{
while (time>0)
{
int i = 1333333; // This number is equivalent to 100 ms
while (i>0)
{
i--;
}
time--;
}
}
///////////////////////////////////////////////////////////////////////////////
///////////
/* ---------------- Function to display Boder ---------------------------- */
void boder(char x)
{
int i;
for(i=1;i<=80;i++)
{
gotoxy(i,1);
cout<<x;
delay(300);
}
for (i=2;i<=23;i++)
{
gotoxy(80,i);
cout<<x;
delay(300);
}
for (i=80;i>=1;i--)
{
gotoxy(i,24);
cout<<x;
delay(300);
}
for (i=23;i>=2;i--)
{
gotoxy(1,i);
cout<<x;
delay(300);
}
delay(1000);
}