
Concept explainers
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;
}

Step by stepSolved in 2 steps

- Computer Science c++ help comment code please. Complex has multiple parameters to overload i think. class Complex{public: Complex(); //There are no parameters because... Complex(double); //There is one parameter because... Complex(double, double);//There are two parameters because... double get_Real(); void set_Real(double); double get_Imaginary(); void set_Imaginary(double); friend ostream& operator << (ostream& out, Complex& r); //explain friend istream& operator >> (istream& in, Complex& r);//explainprivate: double real; double imaginary;}; ostream& operator << (ostream& out, Complex& r) //{ double a = r.get_Real(); double b = r.get_Imaginary(); if (a != 0)out << a; if (b < 0) out << "-" << abs(b) << "i"; if (b > 0 && b != 1) out << "+" << b << "i"; if (b == 0) out << "0"; if (b == 1 && a != 0) out << "+" <<…arrow_forwardclass Airplane – highlights -- planeID : String -planeModel: String //”Boeing 757” etc. --seatCapacity : int //would vary by outfitting ………… Assume getters and setters, toString(), constructor with parameters and constructor ……………… Write lambdas using a standard functional interface to: a) Given a plane object and a required number of seats as an input, determine if the given plane meets or exceeds the required capacity b) Output the plane description if capacity is less than 80% of a specified number (We would use his for planning aircraft assigned to various routes. ) c) Adjust the seats in a plane by a specified positive or negative number [after modifications have been made to the interior.] …and write an example for each showing the usage, using an Airplane instance plane1arrow_forwardPlease help with the following: C# .NET change the main class so that the user is the one that as to put the name a driver class that prompts for the person’s data input, instantiates an object of class HealtProfile and displays the patient’s information from that object by calling the DisplayHealthRecord, method. MAIN CLASS---------------------- static void Main(string[] args) { // instance of patient record with each of the 4 parameters taking in a value HeartRates heartRate = new HeartRates("James", "Kill", 1988, 2021); heartRate.DisplayPatientRecord(); // call the method to display The Patient Record } CLASS HeartRATES------------------- class HeartRates { //class attributes private private string _First_Name; private string _Last_Name; private int _Birth_Year; private int _Current_Year; // Constructor which receives private parameters to initialize variables public HeartRates(string First_Name, string Last_Name, int Birth_Year, int Current_Year) { _First_Name = First_Name;…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





