This code doesn't work, please help me. -----------------------------------   #include #include using namespace std;   class Taxi {   private: string driver_name; string maker; string color;   public: int calls; int passengers; static int Tpassengers; Taxi(string name, string maker, string color) { this->driver_name=name; this->maker=maker; this->color=color; this->passengers=0; this->calls=0; }   Taxi(int pass) { this->passengers=pass; } int NPassenger() { int x = (rand()%10)+1; return x; }   Taxi operator += (const Taxi x){ this->passengers +=x.passengers; this->calls+=1; return *this; } void write_Taxi_info() {   ofstream outFile; outFile.open("CTC.txt", std::ios_base::app);   outFile.close(); }   }; int Taxi::Tpassengers{0}; int main() { srand((unsigned)time(0));   Taxi** taxis = new Taxi*[6]; taxis[0] = new Taxi("xyz qwe","erty","blue"); taxis[1] = new Taxi("xyz qwe","erty","blue"); taxis[2] = new Taxi("xyz qwe","erty","blue"); taxis[3] = new Taxi("xyz qwe","erty","blue"); taxis[4] = new Taxi("xyz qwe","erty","blue"); taxis[5] = new Taxi("xyz qwe","erty","blue"); char choice; cout <<"\nWelcome to CTC Taxi."; do{ cout <<"\nDo you need a taxi?\n"; cin >>choice; if(choice!='Y' && choice!='y') { break; } int taxi = rand()%6; cout <<"Taxi #"<NPassenger(); Taxi* temp = new Taxi(pass); *taxis[taxi]+=*temp; Taxi::Tpassengers+=pass; }while(1);      cout << "************************************************************************" <calls <<" calls\t\t"<< taxis[1]->calls <<" calls\t\t"<< taxis[2]->calls <<" calls\t\t"<< taxis[3]->calls <<" calls\t\t"<< taxis[4]->calls <<" calls\t\t"<< taxis[5]->calls <<" calls\n"<< taxis[0]->passengers <<"passengers\t"<< taxis[1]->passengers <<"passengers\t"<< taxis[2]->passengers <<"passengers\t" << taxis[3]->passengers <<"passengers\t"<< taxis[4]->passengers <<"passengers\t"<< taxis[5]->passengers <<"passengers\n"; cout<< "**************************************************************************************************"<passengers; for(int i=1;i<6;i++) { if(taxis[i]->passengers>taxis[index]->passengers) { index=i; } sum+=taxis[i]->passengers; } cout<<"Today taxi "<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This code doesn't work, please help me.

-----------------------------------

 

#include<iomanip>

#include <fstream>

using namespace std;

 

class Taxi

{

 

private:

string driver_name;

string maker;

string color;

 

public:

int calls;

int passengers;

static int Tpassengers;

Taxi(string name, string maker, string color)

{

this->driver_name=name;

this->maker=maker;

this->color=color;

this->passengers=0;

this->calls=0;

}

 

Taxi(int pass)

{

this->passengers=pass;

}

int NPassenger()

{

int x = (rand()%10)+1;

return x;

}

 

Taxi operator += (const Taxi x){

this->passengers +=x.passengers;

this->calls+=1;

return *this;

}

void write_Taxi_info()

{

 

ofstream outFile;

outFile.open("CTC.txt", std::ios_base::app);

 

outFile.close();

}

 

};

int Taxi::Tpassengers{0};

int main()

{

srand((unsigned)time(0));

 

Taxi** taxis = new Taxi*[6];

taxis[0] = new Taxi("xyz qwe","erty","blue");

taxis[1] = new Taxi("xyz qwe","erty","blue");

taxis[2] = new Taxi("xyz qwe","erty","blue");

taxis[3] = new Taxi("xyz qwe","erty","blue");

taxis[4] = new Taxi("xyz qwe","erty","blue");

taxis[5] = new Taxi("xyz qwe","erty","blue");

char choice;

cout <<"\nWelcome to CTC Taxi.";

do{

cout <<"\nDo you need a taxi?\n";

cin >>choice;

if(choice!='Y' && choice!='y')

{

break;

}

int taxi = rand()%6;

cout <<"Taxi #"<<taxi+1<<" will pick you up in a few minutes.";

int pass=taxis[taxi]->NPassenger();

Taxi* temp = new Taxi(pass);

*taxis[taxi]+=*temp;

Taxi::Tpassengers+=pass;

}while(1);

    

cout << "************************************************************************" <<endl;

cout <<"\t\t*CTC Taxi served a total of "<< Taxi::Tpassengers <<" passengers today.**\n";

cout <<"***************************************************************************"<<endl;

cout <<"**********************************************************************"<<endl;

cout << "*Each taxi serve total number of passenger in this shift as bellow:**\n";

cout <<"***********************************************************************************************"<<endl;

cout <<"\nTaxi1\t\tTaxi2\t\tTaxi3\t\tTaxi4\t\tTaxi5\t\tTaxi6\n"<< taxis[0]->calls <<" calls\t\t"<< taxis[1]->calls

<<" calls\t\t"<< taxis[2]->calls <<" calls\t\t"<< taxis[3]->calls <<" calls\t\t"<< taxis[4]->calls <<" calls\t\t"<< taxis[5]->calls

<<" calls\n"<< taxis[0]->passengers <<"passengers\t"<< taxis[1]->passengers <<"passengers\t"<< taxis[2]->passengers <<"passengers\t"

<< taxis[3]->passengers <<"passengers\t"<< taxis[4]->passengers <<"passengers\t"<< taxis[5]->passengers <<"passengers\n";

cout<< "**************************************************************************************************"<<endl;

 

int index=0;

int sum=taxis[0]->passengers;

for(int i=1;i<6;i++)

{

if(taxis[i]->passengers>taxis[index]->passengers)

{

index=i;

}

sum+=taxis[i]->passengers;

}

cout<<"Today taxi "<<index+1<<" served most passengers.\n";

cout<<"Today on average each taxi served "<<fixed<<setprecision(1)<<sum/6.0<<" passengers.\n";

return 0;

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education