•Computer System.
#include <iostream>
#include <fstream>
#include<conio.h>
#include <string>
#include <iomanip>
#include<sstream>
#include <bits/stdc++.h>
using namespace std;
string custname , custaddr , fsearch ;
long long custph;
string Shead ,Scompany , Sbike , Scolor , Sqty,Scar,Spatd;
string fhead ,fcompany ,fbike ,fcar,fpatd, fcolor ,fqty,infosearch;
string Cuscompany , Cusbike ,Cuscar, Cuscolor , Cusqty,Cushead,Cuspatd;
long long newphone;
int linee,newww,m,statee , lcheak = 0,Sday;
int addrforcus();
int termsandcondition();
void time()
{
time_t tmNow;
tmNow = time(NULL);
struct tm t = *localtime(&tmNow);
ofstream fout;
string line;
fout.open(infosearch+".csv", ios::app);
// Execute a loop If file successfully opened
// Write line in file
fout << endl<< t.tm_mday << "-" << "0"<<t.tm_mon + 1 << "-" << t.tm_year + 1900 <<",";
// Close the File
fout.close();
}
void logincheak()
{
string cheakname , cheakaddr ,cheakph ,cheakhead;
addrforcus();
termsandcondition();
system("color E4");
cout<<"\n\n\n\t\t\t\t\tEnter your Full name : ";
getline(cin>>ws,custname);
transform(custname.begin(), custname.end(), custname.begin(), ::tolower);
ifstream logc("custinfo.csv");
getline(logc,cheakhead,'\n');
while(logc.peek()!=EOF)
{
getline(logc,cheakname,',');
getline(logc,cheakaddr,',');
getline(logc,cheakph,'\n');
if(custname.compare(cheakname)==0)
{
lcheak = 1;
cout<<"\n\n\n\t\t\t\t\t\t********************************";
cout<<"\n\t\t\t\t\t\t* *";
cout<<"\n\t\t\t\t\t\t* WELCOME BACK !!! *";
cout<<"\n\t\t\t\t\t\t* *";
cout<<"\n\t\t\t\t\t\t********************************";
}
}
}
void entry()
{
details:
cout<<"\n\t\t\t\t\tEnter your address : ";
getline(cin>>ws,custaddr);
mob:
cout<<"\n\t\t\t\t\tEnter your mobile number : ";
cin>>custph;
if(custph>9999999999 || custph<7000000000)
{
cout<<"\n\t\t\t\t\tWrong input";
goto mob;
}
cout<<"\n\t\t\t...............................................................................";
cout<<"\n\n\t\t\t\t\tDo you confirm Below Details\n";
cout<<"\n\t\t\t\t\tName : "<<custname<<endl<<"\t\t\t\t\tAddress : "<<custaddr<<endl<<"\t\t\t\t\tMobile no. : "<<custph<<endl;
cout<<"\n\t\t\t\t\t1.yes\t\t2.No(try again)\t\t3.Exit\n";
char PD;
PD =_getch();
cout<<"\n\t\t\t\t\t"<<PD;
cout<<"\n\t\t\t...............................................................................\n";
switch(PD)
{
case 49:
cout<<"\n\t_______________________________________________________________________________________________________________________________";
cout<<"\n\n\n\t\t\t\t\t\t********************************";
cout<<"\n\t\t\t\t\t\t* *";
cout<<"\n\t\t\t\t\t\t* WELCOME CUSTOMER!!! *";
cout<<"\n\t\t\t\t\t\t* *";
cout<<"\n\t\t\t\t\t\t********************************";
break;
case 50 :
goto details;
break;
case 51:
exit(0);
}
}
void delete_linee(const char *file_name, int n);
void bikebook();
void carbook();
void book()
{
statee = 0;
cout<<"\n\n\t\t\t\t\tChoose vehicle\n\n\t\t\t\t\t1.Bike\t\t2.Car";
char des;
des=_getch();
cout<<"\n\n\t\t\t\t\t"<<des;
switch(des)
{
case 49:
bikebook();
break;
case 50:
carbook();
break;
}
}
void carbook()
{
Sday = 0;
fsearch = "carstock";
restartcar:
cout<<"\n\t\t\t...............................................................................\n";
cout<<"\n\n\t\t\t\t\tChoose Company\n\n\t\t\t\t\t1.TATA\t\t2.Hyundai\n";//choose company of Car....
char CScompany;
SCarcompany:
CScompany =_getch();
cout<<"\n\n\t\t\t\t\t"<<CScompany<<endl;
switch(CScompany)
{
case 49:
Scompany = "TATA";
cout<<"\n\n\t\t\t\t\tChoose Car\n\n\t\t\t\t\t1.Nexon\t\t2.Tiago\t\t3.Harrier"; // choose Car........
char TATAcar;
TATAcar =_getch();
cout<<"\n\n\t\t\t\t\t"<<TATAcar<<endl;//TATA...................................
switch(TATAcar)
{
case 49:
Scar = "nexon";
break;
case 50:
Scar = "tiago";
break;
case 51:
Scar= "harrier";
break;
}
break;
case 50:
Scompany = "hyundai";
cout<<"\n\n\t\t\t\t\tChoose Car\n\n\t\t\t\t\t1.i10\t\t2.i20\t\t3.Creta\n"; // choose Car........
char hyundaicar;
hyundaicar =_getch();
cout<<"\n\n\t\t\t\t\t"<<hyundaicar<<endl;//hyndai..................................
switch(hyundaicar)
{
case 49:
Scar = "i10";
break;
case 50:
Scar = "i20";
break;
case 51:
Scar = "creta";
break;
}
break;
default :
goto SCarcompany;
}
cout<<"\n\t\t\t...............................................................................\n";
cout<<"\n\n\t\t\t\t\tChoose color for the Car\n\n\t\t\t\t\t1.White\t\t2.black\n";
char Ccolor;
Ccolor =_getch();
cout<<"\n\n\t\t\t\t\t"<<Ccolor<<endl;
switch(Ccolor)
{
case 49:
Scolor ="white";
break;
case 50:
Scolor ="black";
break;
}
cout<<"\n\t\t\t...............................................................................\n";
cout<<"\n\n\t\t\t\t\tChoose type of oil\n\n\t\t\t\t\t1.petrol\t\t2.Diesel\n";
char patd;
patd =_getch();
cout<<"\n\n\t\t\t\t\t"<<patd<<endl;
switch(patd)
{
case 49:
Spatd ="petrol";
break;
case 50:
Spatd ="disel";
break;
}
cout<<"\n\t\t\t...............................................................................\n";
cout<<"\n\n\t\t\t\t\tEnter Number of Days you want to book : ";
cin>>Sday;
int rent;
rent = (Sday+400)*6;
cout<<"\n\n\t\t\t\t\tYour Rent :- "<<rent<<"Rs.";
ifstream readcar(fsearch+".csv");
getline(readcar,fhead,'\n');
while(readcar.peek()!=EOF)
{
getline(readcar,fcompany,',');
getline(readcar,fcar,',');
getline(readcar,fcolor,',');
getline(readcar,fpatd,',');
getline(readcar,fqty,'\n');
if(Scompany.compare(fcompany)==0)
{
if(Scar.compare(fcar)==0)
{
if(Scolor.compare(fcolor)==0)
{
if(Spatd.compare(fpatd)==0)
{
if(fqty.compare("0")==0)
{
cout<<"\n\n\t\t\t\t\tSorry But this CAR is Not available\n\t\t\t\t\tchoose another\n";
goto restartcar;
}
else
{
cout<<"\n\n\t\t\t\t\t .............................";
cout<<"\n\t\t\t\t\t\tYour car is Booked\n";
cout<<"\t\t\t\t\t .............................";
statee = 1;
}
infosearch ="carinfo";
time();
ofstream client(infosearch+".csv",ios::app);
client<<custname<<","<<Scompany<<","<<Scar<<","<<Scolor<<","<<Spatd<<","<<Sday;
client.close();
if(lcheak == 0 )
{
ofstream pinfo("custinfo.csv",ios::app);
pinfo<<endl<<custname<<","<<custaddr<<","<<custph;
pinfo.close();
}
}
}
}
}
}
readcar.close();
if(statee == 1)
{
linee = 0;
//statee = 0;
m = 0;
ifstream readcar("carstock.csv");
getline(readcar,Cushead,'\n');
linee = linee+1;
while(readcar.peek()!=EOF)
{
getline(readcar,Cuscompany,',');
getline(readcar,Cuscar,',');
getline(readcar,Cuscolor,',');
getline(readcar,Cuspatd,',');
getline(readcar,Cusqty,'\n');
linee = linee+1;
if(Scompany.compare(Cuscompany)==0)
{
if(Scar.compare(Cuscar)==0)
{
if(Scolor.compare(Cuscolor)==0)
{
if(Spatd.compare(Cuspatd)==0)
{
m = linee;
stringstream convert(Cusqty);
newww = 0;
convert >> newww;
statee = 1;
}
}
}
}
}
readcar.close();
}
if(statee == 1)
{
delete_linee("carstock.csv",m);
ofstream carst("carstock.csv",ios::app);
carst<<"\n"<<Scompany<<","<<Scar<<","<<Scolor<<","<<Spatd<<","<<newww-1;
carst.close();
}
}
void bikebook()
{
Sday = 0;
fsearch = "bikestock";
restart:
cout<<"\n\t\t\t...............................................................................\n";
cout<<"\n\n\t\t\t\t\tChoose Company\n\n\t\t\t\t\t1.Suzuki\t\t2.TVS";//choose company of bike.....
char BScompany;
BScompany =_getch();
cout<<"\n\n\t\t\t\t\t"<<BScompany<<endl;
switch(BScompany)
{
case 49:
Scompany = "suzuki";
cout<<"\n\n\t\t\t\t\tChoose Bike\n\n\t\t\t\t\t1.Access125\t\t2.Gixxer\t\t3.Intruder\n"; // choose Bike........
char suzukiBike;
suzukiBike =_getch();
cout<<"\n\n\t\t\t\t\t"<<suzukiBike<<endl;
switch(suzukiBike)
{
case 49:
Sbike = "access125";
break;
case 50:
Sbike = "gixxer";
break;
case 51:
Sbike = "intruder";
break;
}
break;
case 50:
Scompany = "TVS";
cout<<"\n\n\t\t\t\t\tChoose Bike\n\n\t\t\t\t\t1.Jupiter\t\t2.Star City plus\t\t3.Ntorq\n"; // choose Bike........
char tvsBike;
tvsBike =_getch();
cout<<"\n\n\t\t\t\t\t"<<tvsBike<<endl;
switch(tvsBike)
{
case 49:
Sbike = "Jupiter";
break;
case 50:
Sbike = "Star city plus";
break;
case 51:
Sbike = "Ntorq";
break;
}
}
cout<<"\n\t\t\t...............................................................................\n";
cout<<"\n\n\t\t\t\t\tChoose color for the bike\n\n\t\t\t\t\t1.White\t\t2.black\n";
char bcolor;
bcolor =_getch();
cout<<"\n\n\t\t\t\t\t"<<bcolor<<endl;
switch(bcolor)
{
case 49:
Scolor ="white";
break;
case 50:
Scolor ="black";
break;
}
cout<<"\n\t\t\t...............................................................................\n";
cout<<"\n\n\t\t\t\t\tEnter Number of Days you want to book : ";
cin>>Sday;
int rent;
rent = (Sday+400)*6;
cout<<"\n\n\t\t\t\t\tYour Rent :- "<<rent<<"Rs.";
ifstream readbike(fsearch+".csv");
getline(readbike,fhead,'\n');
while(readbike.peek()!=EOF)
{
getline(readbike,fcompany,',');
getline(readbike,fbike,',');
getline(readbike,fcolor,',');
getline(readbike,fqty,'\n');
if(Scompany.compare(fcompany)==0)
{
if(Sbike.compare(fbike)==0)
{
if(Scolor.compare(fcolor)==0)
{
if(fqty.compare("0")==0)
{
cout<<"\n\n\t\t\t\t\tSorry But this Bike is Not available\nchoose another\n";
goto restart;
}
else
{
cout<<"\n\n\t\t\t\t\t .............................";
cout<<"\n\t\t\t\t\t\tYour car is Booked\n";
cout<<"\t\t\t\t\t .............................";
statee = 1;
}
infosearch ="bikeinfo";
time();
ofstream client(infosearch+".csv",ios::app);
client<<custname<<","<<Scompany<<","<<Sbike<<","<<Scolor<<","<<Sday;
client.close();
if(lcheak == 0 )
{
ofstream pinfo("custinfo.csv",ios::app);
pinfo<<endl<<custname<<","<<custaddr<<","<<custph;
pinfo.close();
}
}
}
}
}
readbike.close();
if(statee == 1)
{
linee = 0;
//statee = 0;
m = 0;
ifstream readbike("bikestock.csv");
getline(readbike,Cushead,'\n');
linee = linee+1;
while(readbike.peek()!=EOF)
{
getline(readbike,Cuscompany,',');
getline(readbike,Cusbike,',');
getline(readbike,Cuscolor,',');
getline(readbike,Cusqty,'\n');
linee = linee+1;
if(Scompany.compare(Cuscompany)==0)
{
if(Sbike.compare(Cusbike)==0)
{
if(Scolor.compare(Cuscolor)==0)
{
m = linee;
stringstream convert(Cusqty);
newww = 0;
convert >> newww;
statee = 1;
}
}
}
}
readbike.close();
}
if(statee == 1)
{
delete_linee("bikestock.csv",m);
ofstream bikest("bikestock.csv",ios::app);
bikest<<"\n"<<Scompany<<","<<Sbike<<","<<Scolor<<","<<newww-1;
bikest.close();
}
}
void delete_linee(const char *file_name, int m)
{
// open file in read mode or in mode
ifstream iss(file_name);
// open file in write mode or out mode
ofstream ofss;
ofss.open("temp.txt", ofstream::out);
// loop getting single characters
char c;
int line_no =1;
while (iss.get(c))
{
// if a newline character
if (c == '\n')
line_no++;
// file content not to be deleted
if (line_no != m)
ofss << c;
}
// closing output file
ofss.close();
// closing input file
iss.close();
// remove the original file
remove(file_name);
// rename the file
rename("temp.txt", file_name);
}
int addrforcus()
{
system("color C0");
cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\t______________________________________________________________________________________________________________________";
cout<<"\n\n\t\t\t\t\tCompany address:-";
cout<<"\n\t\t\t\t\t\t\tKasaba Bawada , Near D.Y.Patil medical collage , shop no. 4 , kolhapur , maharashtra";
cout<<"\n\n\t\t\t______________________________________________________________________________________________________________________";
cout<<"\n\n\t\t\t\t\tPress... ANY KEY to go ahead >>>";
getch();
system("cls");
}
int termsandcondition()
{
system("color F4");
cout<<"\n\n\n\t\t\t\t\t\t\t********************************";
cout<<"\n\t\t\t\t\t\t\t* *";
cout<<"\n\t\t\t\t\t\t\t* TERMS AND CONDITIONS *";
cout<<"\n\t\t\t\t\t\t\t* *";
cout<<"\n\t\t\t\t\t\t\t********************************";
cout<<"\n\n\t\t\t __________________________________________________________________________________________________";
cout<<"\n\t\t\t| |";
cout<<"\n\t\t\t| |";
cout<<"\n\t\t\t| (1) Age must be 18+. |";
cout<<"\n\t\t\t| (2) Damage for car/bike is your responsibility. |";
cout<<"\n\t\t\t| (3) You have to do 60% payment before we handover you car/bike. |";
cout<<"\n\t\t\t| (4) You have return our car/bike on time otherwise we take extra charges. |";
cout<<"\n\t\t\t| (5) Helmets are provided by our company. |";
cout<<"\n\t\t\t| (6) You have to submit your valid license copy and some of the other documents. |";
cout<<"\n\t\t\t| (7) You should inform the company in advance if you intending to go another city. |";
cout<<"\n\t\t\t| (8) confirmed bookings are non-refundable. |";
cout<<"\n\t\t\t| |";
cout<<"\n\t\t\t| |";
cout<<"\n\t\t\t __________________________________________________________________________________________________";
cout<<"\n\n\n\n\n\n\n\n\t\t\t\t\tPress... ANY KEY to go ahead >>>";
getch();
system("cls");
}