The compiler shows a lot of errors, can you sort this out please? #include<iostr
ID: 3636084 • Letter: T
Question
The compiler shows a lot of errors, can you sort this out please?#include<iostream>
#include<string>
#include<stdio.h>
#include<dos.h>
#include<windows.h>
using namespace std;
inline float convert (float engine)
{return engine * 2.5;}
const int distancelong=100;
const int distanceshort=50;
class car
{
protected:
char category[20];
float engine ;
int model;
string finalcat;
public:
void setcategory()
{
cout<<"Please enter your vehicle category ";
cin>>category;
}
int retmod(){return model;}
void showengine()
{
cout<<" The engine specs are ";
cout<<engine<<" cc "<<endl;
}
void setengine()
{
cout<<"Enter engine specs in cc ";
cin>>engine;
float torque=convert(engine);
cout<<"The torque equivalent is "<<torque<<endl;
}
void setmodel ()
{
cout<<" Enter model (year of make) ";
cin>>model;
}
void showmodel ()
{
cout<<" The model (year of make) is ";
cout<<model<<endl;
}
void catfinal(string nami)
{finalcat=nami;
cout<<"You chose "<<finalcat<<endl;
}
void showcat()
{cout<<category;}
void find(char nam[],int r)
{if(strcmp(category,nam)==0)
{cout<<" *SEARCH SUCCESFULL* ";
cout<<" Category found at garage number "<<r+1<<endl;
}
else cout<<" Not found at garage number "<<r+1<<endl;
}
};
class customer
{
protected:
int id,age;
string name;
public:
int choice;
class ids{};
class ages{};
void showrules()
{
cout<<" WE WILL SIMULATE A SCHEME WHICH WILL LET US DECIDE THE NUMBER OF HOURS THE CAR IS BORROWED ";
cout<<" AND GAUGE THE CONDITION IT IS RECEIVED BACK IN THE COMPANY'S GARAGE. THIS WILL BE A SIMPLE MEMORY GAME, THE HIGHER THE DIFFICULTY LEVEL (2 STAGES), HIGHER THE NUMBER OF HOURS THE CAR WILL BE DEEMED TO BE BORROWED BY THE USER ";
cout<<" YOUR PERFORMANCE WILL DETERMINE THE CONDITION THE CAR IS RETURNED IN BACK TO THE COMPANY ";
cout<<" YOU WILL BE SHOWN A COUPLE OF TRAFFIC STATISTICS FIRST. THE VEHICLE WOULD HAVE TO COVER A CERTAIN DISTANCE (DEPENDING ON NUMBER OF HOURS RENTED), AND THROUGHOUT THIS JOURNEY YOU WILL BE QUIZZED REGULARLY ABOUT THE STATISTICS SHOWN PREVIOUSLY. A SIMPLE SCORING SYSTEM WILL BE INTRODUCED, WHERE EACH INCORRECT ANSWER WILL RESULT IN THE CAR'S CONDITION DETERIORATING. ";
cout<<" IF YOU DO NOT TURN IN THE CAR AFTER THE STIPULATED TIME FRAME, OR DRIVE TOO RASHLY---BEWARE!!! ";
}
void setname()
{
cout<<"Please enter your Name ";
cin>>name;
}
void showage()
{
cout<<" Age is ";
cout<<age<<endl;
}
void setage()
{
cout<<" Enter age ";
cin>>age;
if(age<18)
{throw ages();}
cout<<endl;
}
void setid ()
{
cout<<" Enter your id number ";
cin>>id;
if(id<=0)
{throw ids();}
cout<<endl;
}
void showid ()
{
cout<<" ID number is ";
cout<<id<<endl;
}
void dlevel()
{
cout<<" Please enter the number of hours you will rent the car(6 or 12) ";
cin>>choice;
cout<<endl;
}
int slevel()
{
return choice;
}
void shownamey()
{cout<<name<<endl;}
//friend void invoice::cid();
};
class game:public customer
{
protected:
int distE,choise;
public:
int conditioneasy;
game(){conditioneasy=100;distE=0;}
virtual void showlevel()
{
Sleep(2000);
system("cls");
cout<<" Difficulty level is EASY! ";
cout<<"PAY CLOSE ATTENTION TO THESE STATS! ";
Sleep(3000);
system("cls");
cout<<" Please check your engine_oil ";
Sleep(1500);
system("cls");
cout<<"Take the first left ";
Sleep(1500);
system("cls");
cout<<" Speed limit on the highway is 60 miles per hour ";
Sleep(1500);
system("cls");
cout<<"Slow down at checkpost ";
Sleep(1500);
system("cls");
cout<<" Dont overtake from the left side! ";
Sleep(1500);
system("cls");
}
virtual int advance()
{
while(distE<=40)
{distE+=10;
cout<<" "<<distE<<"Km";
if (distE==10)
{cout<<" What do you need to check before starting your journey? ";
char ans1[20];
cin>>ans1;
char s1[20]="engine_oil";
if(strcmp(s1,ans1)==0)
cout<<" Nice job! ";
else {cout<<"OOPS Wrong Answer! "; conditioneasy-=10;}
}
if (distE==30)
{cout<<" What is the speed limit on the highway (digits only) ? ";
int ans;
cin>>ans;
if(ans==60)
cout<<" Nice job! ";
else {cout<<"OOPS Wrong Answer! "; conditioneasy-=10;}
}
if (distE==50) {cout<<" Your journey is over, return the car now!!! ";
cout<<"Press 1 to return to company, and 2 (at your own risk) ";
cin>>choise;
if(choise==2)
{
return distE;
}}
Sleep(3000);
}
return 0;
}
int cond{ return conditioneasy;}
void operator < (game g1)
{
g1.distE=60;
distE=0;
system("cls");
cout<<"Think you can get away!? Weve got police cars faster than yours !!! ";
cout<<"See for yourself! ";
Sleep(5000);
while(distE<g1.distE)
{
system("cls");
cout<<distE<<" Km COP CAR ";
cout<<g1.distE<<" Km YOUR CAR ";
Sleep(3000);
system("cls");
distE+=20;
g1.distE+=10;
}
cout<<" GOT YOU!! You risked jail just for an extra "<< g1.distE-60<<" kilometers, WOW! ";
}
};
class diff:public game
{
protected:
int distD,ans,fee;
public:
int conditiondiff;
diff(){conditiondiff=100; distD=0;}
void showlevel()
{
Sleep(1000);
system("cls");
cout<<" Difficulty level is DIFFICULT! ";
cout<<"PAY CLOSE ATTENTION TO THESE STATS! ";
Sleep(2500);
system("cls");
cout<<" Please check your fuel ";
Sleep(1400);
system("cls");
cout<<"Turn left at roundabout ";
Sleep(1400);
system("cls");
cout<<" Mind the pedestrians at Nazim road! ";
Sleep(1400);
system("cls");
cout<<" 50 Rs toll plaza fee ";
Sleep(1400);
system("cls");
cout<<"Slow down at checkpost ";
Sleep(1400);
system("cls");
cout<<" The speed limit on highway is 70 miles per hour ";
Sleep(1000);
system("cls");
}
int advance()
{
while(distD<=90)
{
distD+=10;
cout<<" "<<distD<<"Km";
if (distD==10)
{cout<<" What do you need to check before starting your journey? ";
char ans2[20];
cin>>ans2;
char s2[20]="fuel";
if(strcmp(s2,ans2)==0)
cout<<" Nice job! ";
else {cout<<"OOPS Wrong Answer "; conditiondiff-=10;}
}
if (distD==40)
{cout<<" What is the speed limit on the highway? ";
cin>>ans;
if(ans==70)
{
cout<<" Nice job! ";
}
else {cout<<"OOPS Wrong Answer "; conditiondiff-=10;}
}
if (distD==70)
{cout<<" What is toll plaza fee? ";
cin>>fee;
if(fee==50)
{
cout<<" Nice job! ";
}
else {cout<<"OOPS Wrong Answer "; conditiondiff-=10;}
}
Sleep(3000);
}
if (distD==100)
cout<<" Your journey is over, return the car now!!! ";
return 0;
}
int cond {return conditiondiff;}
};
class invoice : public diff,public car
{
protected : float money,totalmoney,choise,ceasy,cdiff;
//from class car, data member finalcat shown below
public :
void coneasy(int a){ceasy=a;}
void condif(int b){cdiff=b;}
void set(int x){choise=x;}
void carcost()
{
cout<<"LALA";
if (finalcat=="Sedan") {money=100; cout<<" Price of this car per hour is "<<money<<endl<<endl;}
if (finalcat=="Cruiser") {money=200; cout<<" Price of this car per hour is "<<money<<endl<<endl;}
if (finalcat== "Jeep") {money= 250; cout<<" Price of this car per hour is "<<money<<endl<<endl;}
if (finalcat== "Van") {money=300; cout<<" Price of this car per hour is "<<money<<endl<<endl;}
if (finalcat=="Luxury") {money=600; cout<<" Price of this car per hour is "<<money<<endl<<endl;}
}
//Consider "choice" from class customer
//"conditioneasy" is data member from class game
//"conditiondiff" is data member from class diff
void rentcost()
{
totalmoney=0;
cout<<"LALA";
//IF CAR RENTED FOR 6 HOURS
if (choise == 6)
{ totalmoney=money*6;
if
(ceasy==100) totalmoney*=1;
if
(ceasy==90) totalmoney*=1.1;
if
(ceasy==80) totalmoney*=1.2;
cout<<" Total cost is " << totalmoney<<endl<<endl;
}
//IF CAR RENTED FOR 12 HOURS
if (choise == 12)
{ totalmoney=money*12;
if
(cdiff==100) totalmoney*=1;
if
(cdiff==90) totalmoney*=1.1;
if
(cdiff==80) totalmoney*=1.2;
if
(cdiff==70) totalmoney*=1.3;
cout<<" Total cost is " << totalmoney<<endl<<endl;
}}
//From class customer display the following data : {NAME , AGE , ID}
void cid()
{
cout<<" Customer identification ";
cout<<name<<endl;
cout<<age<<endl;
cout<<id<<endl;
}
};
void main()
{
// MANAGER MODE
cout<<" NOTE TO MANAGER ";
cout<<"Please enter car category (We have Sedan,Cruiser,Jeep,Van,Luxury), engine specification, and model (year of make) ";
cout<<" Please Enter model year of cars from oldest to most recent ";
car manager[5];
car choice;
char names[50];
for(int u=0;u<5;u++)
{
manager[u].setmodel();
manager[u].setcategory();
manager[u].setengine();
}
cout<<" TO THE MANAGER - YOUR WORK IS DONE! ";
cout<<" A CUSTOMER WANTS TO RENT A CAR!, DO WE HAVE YOUR PERMISSION? (Y N) ";
char ans;
cin>>ans;
if (ans=='Y'||ans=='y')
system("cls");
else exit(1);
////category search
//////// USER
cout<<" WELCOME USER ";
cout<<"Enter vehicle category to search, lets hope we have your preferred choice! ";
cout<< " ( We have got 5 categories! ) ";
cin>>names;
system("cls");
cout<<" Take a look at the results ";
for (int y=0;y<5;y++)
{
manager[y].find(names,y);
}
Sleep(5000);
/////////////model no's
system("cls");
cout<<" Now please enter model number to search ";
int element;
cin>>element;
int lb=0,ub=4,mid;
for(;lb<=ub;)
{
mid=(lb+ub)/2;
if(manager[mid].retmod()==element)
{
cout<<" *SEARCH SUCCESSFUL* ";
cout<<"Model found at garage number "<<mid<<endl;
Sleep(3500);
system("cls");
break;
}
else if(element>manager[mid].retmod()){
lb=mid+1;
}
else if(element<manager[mid].retmod()){
ub=mid-1;
}
}
cout<<" If the prompt SEARCH SUCCESFUL was not displayed this means we dont have said model ";
cout<<" We have available, the following vehicles ";
for(int v=0;v<5;v++)
{
manager[v].showcat();
manager[v].showengine();
manager[v].showmodel();
cout<<endl<<endl<<endl;
}
cout<<"Please enter your final choice of vehicle category now, have a nice day :) ";
string choices;
cin>>choices;
//invoice customer1;
choice.catfinal(choices);
//customer1.catfinal(choices);
customer one;
//one.dlevel();
//one.setname();
try
{one.setage();
}
catch(customer::ages)
{
cout<<" You are too young to rent a car ";
exit(1);
}
try{
one.setid();
}
catch(customer::ids)
{
cout<<" ID can not be negative!!! ";
exit(1);
}
one.showrules();
//game two;
//two.showlevel();
game two;
two.dlevel();
two.setname();
int x=two.slevel();
diff d;
game cop;
game*g;
g=&two;
if(x==6)
{
g->showlevel();
int p = g->cond(); // conditioneasy
int r=g->advance();
if(r==50)
{
cop<two;
}
//g->quiz();
}
if(x==12)
{
g=&d;
g->showlevel();
g->advance();
int y = g->cond(); // conditiondiff
}
invoice customer1;
customer1.set(x);
customer1.coneasy(p);
customer1.condif(y);
customer1.catfinal(choices);
customer1.shownamey();
cout<<endl;
customer1.showage();
cout<<endl;
customer1.showid();
cout<<endl;
customer1.carcost();
cout<<endl;
customer1.rentcost();
cout<<" PAY UP ! ";
}
Explanation / Answer
#include #include #include #include #include using namespace std; inline float convert (float engine) {return engine * 2.5;} const int distancelong=100; const int distanceshort=50; class car { protected: char category[20]; float engine ; int model; string finalcat; public: void setcategory() { coutcategory; } int retmod(){return model;} void showengine() { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.