Вы находитесь на странице: 1из 11

#include<iosteam.

h>
#include<fsteam.h>
#include<stdio.h>
#include<string.h>
class fleet
{
char car_code[20];
char car_name[25];
char car_colour[10];
char car_type[10];
Int rentpk;
Int fixed_rent;
public;
void add()
{
cout<<end;
cout<<”ENTER THE CAR NAME:”;
gets(car_name);
cout<<”ENTER THE CAR TYPE”;
gets(car_type);
cout<<”ENTER CAR COLOUR:”;
gets(car_colour);
cout<<”ENTER RENT/km:”;
cin>fixed_rent;
cout<<”ENTER FIXED RENT:”;
cin>>fixed_rent;
cout << car_name<<”\tHAS BEEN ADDED TO OUR FLEET!!!”;
void display()
{
cout<<”/nCar Name :”<<car_name;
cout<<”/nCar Type:”<<car_type;
cout<<”/nCar code:”<<car_column;
cout<<”/nRent/km:”<<rentpk;
cout<< “/nFixed rent:”<<fixed_rent<<end
}
char*return_code()
{
return car_code;
}
char*return_type()
{
return car_type;
}
Char*return_car_name()
{
return car_name;
}
longbill(long kms);
}
return fixed_rent(rentpk*kms);
}
rentpk*k;
}
};
void add_new code()
{
fleet obj;
char ans;
ofstreme ofile(“A.dat”;ios:binary|ios:app);
do
{
obj.add();
ofile.write((char*)&obj,sizeof(obj));
cout<<”\n\nDo you want to enter more cars??(Y/N):”;
cin>>ans;
}
while(ans==’Y’);
ofile.close();

void display_fleet()
fleet obj;
ifstream ofile(“A.dat”,ios::binary);
cout<,”\n\t\t My fleet “<<end;
while(ofile.read(char*)obj,sizeof(obj)))
{
obj.display(0;
}
ofile.close();
}
void search_record()
{
fleet x;
fstream sfile(“A.dt”,ios::binary[ios::in][ios::out]);
char ctype[10];
cout<<:Enter the car type to search=”;
gets(ctype);
cout<<end;
cout<<”\n\t\t---“”:SEARCH RESULT:””---“<<end:
while(sfile.read(char*)&x.sizeof(x))
{
if(*(x.return_type())==*ctype)
{
x.display();
}
}
sfile.close();
}
Void renting_car()
{
char cust_name[30];
char car_code[10];
long kms;
cout<<”please enter your name:”;
gets(cust_name);
display_fleet(0;
cout<<”Enter the car you want to rent:”;
gets(car_code);
cou<<”Enter the expected kms for rent:”;
cin>>kms;
fleet obj;
ifstream ofile(“A.dat”,ios::binary);
while(ofile.read((char*)&obj,sizeof(obj))
{
if(strcmp(car_code,obj.return_code())==0)
{
cout<<”-------------“<<endl;
cout<<”\t\tBILL”<<endl;
cout<<:\t****************”<,endl;
cout<<”\tcustomers name:”<<cust_name<<end;
cout<<”-----------------------“<<end;
obj.display();
cout<<’\tTotal kilometres travelled:”<<kms<<”kms”<<end;
cout<<”\tRent of car:Rs”<,obj.bill(kms)<<endl;
cout<<”-------------“<<endl;
}
}
ofile.close();
}
void delete_car()
{
ifstream ifile(“A.dat”,ios::binary);
ofstream ofile(“temp.dat”,ios::binary);
fleet obj:char ccode[10];
cout<<”Enter the code of car to be deleted:”;
cin>ccode;
while(ifile.read((char*)&obj.sizeof(obj))
{
if(strcmpi[ccode.obj].return_code()):=0)
{
ofile(strcmpi(ccode.obj,sizeof(obj));
cout<<”record deleted…………”:
}
}
ifile.close();
ofile.close();
remove(“A.dat”);
rename(“temp.dat,”,”A.dat”)
}
fstream pfile(“A.dat”,ios::binary|ios::in|ios::out);
pfile.close();
remove(“A.dat”);
cout<<”\nALL RECORDS ARE DELETED::”<<endl;
}
void delete_menu()
{
int choi;
cout<<”\n\t………………DELETE MENU…..”<<endl;
cout<<”\n\t1.Delete a car record”<<endl;
cout<<”\n\t2.Delete all car records”<<endl;
cout<<”\t………………….”<<endl;
cin>>choi;
cout<<endl;
switch(choi)
{
case1:delete_car();
break;
case2:delete_all();
break;
default:cout<<”please enter a valid coice::”<<endl;
}
}

void rent_modify()
{
fleet obj:char(code[5]);
cout,,”Enter car code:”;
cin>code;
fstream ofile(“A.dat”,ios::binary|ios::out);
while(ofile.read((char*)&obj.sizeof(obj)))
{
if(strcmpi(code.obj.return_code())==0)
{
cout<<”\n~~~~~~DETAIlS~~~~~~<<end;
obj.display()
cout<<”----------“<<endl;
obj.add();
ofile.seekg(0,ios::cur);
ofile.seekkp(ofile.tellg().sizeof(obj));
ofile.write((char*)&obj,sizeof(obj);
cout<<”New rent/km updated!!!!!!!”;
}
}

ofile.close();
}
Void modify_whole()
{
fleet obj:char code[s];
cout<<”Enter car code:”;
cin>>code;
fstream ofile(“A.dat”,ios::binary|ios::in|ios::out);
while(ofile.read((char*)&obj,sizeof(obj)))
{
if (strcmpi(code.obj.return_code())==0
{
cout<<”\n~~~~~~DETAILS~~~~~~~~”<<endl;
obj.display();
cout<<”~~~~~~~~~”;
obj.add();
ofile.seekg(0,ios::cur);
ofile.seekp((ofile.tellg()-sizeof(obj));
ofile.write((char*)&obj,sizeof(obj));
cout<<”\n record updated !!!!!!!!”:
}
}
ofile.close();
}
void modify_menu()
{
int option;
cout<<”\n\t……..MODIFY MENU…………….”<<endl;
cout<<”\n\t.1…...MODIFY whole record”<<endl;
cout<<”\n\t.2……Modify rent/km of a car”<< endl<<endl;
cout<<endl;
switch(option)
{
case1:modify _whole();
break;
case2:rent_modify();
break;
default:cout<<”please enter right choice!!”<<endl;
}
}
Void contact()
{
cout<”\n\r\t we are BIGBOY TOYS:”<<endl;
cout<<”\n1)we provide you with the best care in the”;
cout<<”world for renting purpose”;
cout<<”\n2)Do contact us for any suggestions or any “;
cout<<”feedback on1800-123-1234 or mail at bigboy@toyz.com<<endl;
cout<<\n3)Address:Raj Nagar palm,delhi-110077”<<endl;
cout<<”A company brought to you by yash inc.”<<endl;
}
void main()
{
char optn=’Y’;
do
{
cout<<”\n\t ********renting through BIGBOY TOYz<<endl<<endl;
int choice;
cout<<”\t~~~~~~~~~~OUR MENU~~~~~~~~~~~~”<<endl;
cout<<”\n\t [1.]……..RENT A CAR “<<endl;
cout<<”\n\t [2.]…….ADD CAR RECORDS”<<endl;
cout<<”\n\t [3.]……..SEARCH A RECORD “<<endl;
cout<<”\n\t [4.]…..DELETE RECORD “<<endl;
cout<<”\n\t [5.]…MODIFY RECORD “<<endl;
cout<<”\n\t [6.]….DISPLAY RECORD “<<endl;
cout<<”\n\t [7.]…..CONTACT US “<<endl;
cout<<”\n\tEnter the choice(1-7):”;
cin>>choice;
cout<<endl;
cout<<”……………………”<<endl;
switch(choice)
{
case1:renting_cae();
break;
case2:add_newcar();
break;
case3:search_record();
break;
case4:delete_menu();
break;
case5:modify_menu();
break;
case6:display_menu();
break;
case7:contact();
break;
defaut:cout<<”Enter correct choice out of the given above!!”;
}
cout<<endl;
cout<<”\nDo you want to continue to MAIN MENU(Y\N)?:”;
cin>>optn;
cout<<endl;
}
while(optn==’Y’||optn==’Y’);
cout<<endl;
cout<<”\t\t THANKS…FOR USING OUR SERVICES!!!!”;

Вам также может понравиться