Can you please clean up my code? Because i think there is an implementation problem in the middle. Thank you.  I have attached the airportqueuedata.txt as a screenshot.    #include #include #include   using namespace std;   void enqQ(int&); void deqQ(int&); void clearQ(int&, int&); bool isEmpty(int, int); bool isFull(int, int);     struct planes // data type plane declared via struct { stringrequest; stringflightNum; stringstartingPoint; stringdestination; stringnumberOfPassengers; };   void enqQ(int& rear) // adds data to queue { rear = (rear + 1) % 10; }   void deqQ(int& front) // delets data from queue { front = (front + 1) % 10; }   void clearQ(int& front, int& rear) // clears queue { front = -1; rear = -1; }   bool isEmpty(int front, int rear) // tells if queue is empty or not { if (rear == front) return true; else return false; }   bool isFull(int front, int rear) // tells if queue is full or not { if ((rear + 1) % 10 == front) return true; else return false; }   int main() { planes normalQueue[15]; planes emergencyQueue[10]; planes plane; fstream fin; int normalFront; int normalRear; int emergencyFront; int emergencyRear; int time; string planeInfo;   clearQ(normalFront, normalRear); clearQ(emergencyFront, emergencyRear);     fin.open("Airport Queue Data.txt"); // makes sure that named text is there if (!fin) { cerr << "\ncould not open file"; exit(-1); }   time = 1; // time is declared to 1   while (!fin.eof()) // reads data until end of file { cout << "Time Cycle = " << time << ":00" << endl; // prints time cycle   getline(fin, planeInfo); // gets entire line and puts it in planeInfo which is temp variable   plane.request = planeInfo.substr(0, 8); // these function reads specific characters from planeInfo and stores them into proper areas of the struct plane.flightNum = planeInfo.substr(8, 3); plane.startingPoint = planeInfo.substr(11, 8); plane.destination = planeInfo.substr(19, 8); plane.numberOfPassengers = planeInfo.substr(27, 3);       if (plane.request == "NORMAL  ") // if plane request is normal then it will be place into normal queue { cout << "Plane added to Normal Queue" << endl; enqQ(normalRear); // normalRear increases normalQueue[normalRear] = plane; // adds plane to normalqueue and prints out plane info cout << plane.flightNum << "\t";  cout << plane.startingPoint << "\t"; cout << plane.destination << "\t"; cout << plane.numberOfPassengers << "\n"; cout << "---------------############---------------------\n" << endl; } else { cout << "Plane added to Emergency Queue" << endl; enqQ(emergencyRear); // emergency rear increases  emergencyQueue[emergencyRear] = plane; // adds plane to emergency Queue and prints out plane info cout << plane.flightNum << "\t"; cout << plane.startingPoint << "\t"; cout << plane.destination << "\t"; cout << plane.numberOfPassengers << "\n"; cout << "---------------############---------------------\n" << endl; }   if (time % 2 == 0) // plane will land only if time is even { if (!isEmpty(emergencyFront, emergencyRear)) // checks if emergency queue is empty if not than it will be prioritize to land { cout << "Emergency Plane Landed" << endl; deqQ(emergencyFront); // increments emergency front and print plane info cout << emergencyQueue[emergencyFront].flightNum << "\t"; cout << emergencyQueue[emergencyFront].startingPoint << "\t"; cout << emergencyQueue[emergencyFront].destination << "\t"; cout << emergencyQueue[emergencyFront].numberOfPassengers << endl; cout << "---------------############---------------------\n" << endl;     } else { cout << "Normal Plane Landed" << endl; deqQ(normalFront); // increments normal front and prints plane info cout << normalQueue[normalFront].flightNum << "\t"; cout << normalQueue[normalFront].startingPoint << "\t"; cout << normalQueue[normalFront].destination << "\t"; cout << normalQueue[normalFront].numberOfPassengers << endl; cout << "---------------############---------------------\n" << endl;   } } time++; // increments time if (time > 24) // check time cycle resets to 1 when it reaches 24 { time = 1; } } fin.close(); // closes fin file     cout << "\n\n\n Flights still in Queues" << endl; // prints planes still left in queues   cout << "\nNormal Queue: " << endl; while (!isEmpty(normalFront, normalRear)) // prints planes that are left in normal queue { deqQ(normalFront); cout << normalQueue[normalFront].request << "\t"; cout << normalQueue[normalFront].flightNum << "\t"; cout << normalQueue[normalFront].startingPoint << "\t"; cout << normalQueue[normalFront].destination << "\t"; cout << normalQueue[normalFront].numberOfPassengers << endl; }   cout << "\nEmergency Queue: " << endl; while (!isEmpty(emergencyFront, emergencyRear)) // prints planes that are left in emergency queue { deqQ(emergencyFront);  cout << emergencyQueue[emergencyFront].request << "\t"; cout << emergencyQueue[emergencyFront].flightNum << "\t"; cout << emergencyQueue[emergencyFront].startingPoint << "\t"; cout << emergencyQueue[emergencyFront].destination << "\t"; cout << emergencyQueue[emergencyFront].numberOfPassengers << endl; }   return 0; }

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

Can you please clean up my code? Because i think there is an implementation problem in the middle. Thank you. 

I have attached the airportqueuedata.txt as a screenshot. 

 

#include <iostream>

#include <fstream>

#include <string>

 

using namespace std;

 

void enqQ(int&);

void deqQ(int&);

void clearQ(int&, int&);

bool isEmpty(intint);

bool isFull(intint);

 

 

struct planes // data type plane declared via struct

{

stringrequest;

stringflightNum;

stringstartingPoint;

stringdestination;

stringnumberOfPassengers;

};

 

void enqQ(int& rear) // adds data to queue

{

rear = (rear + 1) % 10;

}

 

void deqQ(int& front) // delets data from queue

{

front = (front + 1) % 10;

}

 

void clearQ(int& front, int& rear) // clears queue

{

front = -1;

rear = -1;

}

 

bool isEmpty(int front, int rear) // tells if queue is empty or not

{

if (rear == front)

return true;

else

return false;

}

 

bool isFull(int front, int rear) // tells if queue is full or not

{

if ((rear + 1) % 10 == front)

return true;

else

return false;

}

 

int main()

{

planes normalQueue[15];

planes emergencyQueue[10];

planes plane;

fstream fin;

int normalFront;

int normalRear;

int emergencyFront;

int emergencyRear;

int time;

string planeInfo;

 

clearQ(normalFront, normalRear);

clearQ(emergencyFront, emergencyRear);

 

 

fin.open("Airport Queue Data.txt"); // makes sure that named text is there

if (!fin)

{

cerr << "\ncould not open file";

exit(-1);

}

 

time = 1; // time is declared to 1

 

while (!fin.eof()) // reads data until end of file

{

cout << "Time Cycle = " << time << ":00" << endl; // prints time cycle

 

getline(fin, planeInfo); // gets entire line and puts it in planeInfo which is temp variable

 

plane.request = planeInfo.substr(0, 8); // these function reads specific characters from planeInfo and stores them into proper areas of the struct

plane.flightNum = planeInfo.substr(8, 3);

plane.startingPoint = planeInfo.substr(11, 8);

plane.destination = planeInfo.substr(19, 8);

plane.numberOfPassengers = planeInfo.substr(27, 3);

 

 

 

if (plane.request == "NORMAL  ") // if plane request is normal then it will be place into normal queue

{

cout << "Plane added to Normal Queue" << endl;

enqQ(normalRear); // normalRear increases

normalQueue[normalRear] = plane; // adds plane to normalqueue and prints out plane info

cout << plane.flightNum << "\t"; 

cout << plane.startingPoint << "\t";

cout << plane.destination << "\t";

cout << plane.numberOfPassengers << "\n";

cout << "---------------############---------------------\n" << endl;

}

else

{

cout << "Plane added to Emergency Queue" << endl;

enqQ(emergencyRear); // emergency rear increases 

emergencyQueue[emergencyRear] = plane; // adds plane to emergency Queue and prints out plane info

cout << plane.flightNum << "\t";

cout << plane.startingPoint << "\t";

cout << plane.destination << "\t";

cout << plane.numberOfPassengers << "\n";

cout << "---------------############---------------------\n" << endl;

}

 

if (time % 2 == 0) // plane will land only if time is even

{

if (!isEmpty(emergencyFront, emergencyRear)) // checks if emergency queue is empty if not than it will be prioritize to land

{

cout << "Emergency Plane Landed" << endl;

deqQ(emergencyFront); // increments emergency front and print plane info

cout << emergencyQueue[emergencyFront].flightNum << "\t";

cout << emergencyQueue[emergencyFront].startingPoint << "\t";

cout << emergencyQueue[emergencyFront].destination << "\t";

cout << emergencyQueue[emergencyFront].numberOfPassengers << endl;

cout << "---------------############---------------------\n" << endl;

 

 

}

else

{

cout << "Normal Plane Landed" << endl;

deqQ(normalFront); // increments normal front and prints plane info

cout << normalQueue[normalFront].flightNum << "\t";

cout << normalQueue[normalFront].startingPoint << "\t";

cout << normalQueue[normalFront].destination << "\t";

cout << normalQueue[normalFront].numberOfPassengers << endl;

cout << "---------------############---------------------\n" << endl;

 

}

}

time++; // increments time

if (time > 24) // check time cycle resets to 1 when it reaches 24

{

time = 1;

}

}

fin.close(); // closes fin file

 

 

cout << "\n\n\n Flights still in Queues" << endl; // prints planes still left in queues

 

cout << "\nNormal Queue: " << endl;

while (!isEmpty(normalFront, normalRear)) // prints planes that are left in normal queue

{

deqQ(normalFront);

cout << normalQueue[normalFront].request << "\t";

cout << normalQueue[normalFront].flightNum << "\t";

cout << normalQueue[normalFront].startingPoint << "\t";

cout << normalQueue[normalFront].destination << "\t";

cout << normalQueue[normalFront].numberOfPassengers << endl;

}

 

cout << "\nEmergency Queue: " << endl;

while (!isEmpty(emergencyFront, emergencyRear)) // prints planes that are left in emergency queue

{

deqQ(emergencyFront); 

cout << emergencyQueue[emergencyFront].request << "\t";

cout << emergencyQueue[emergencyFront].flightNum << "\t";

cout << emergencyQueue[emergencyFront].startingPoint << "\t";

cout << emergencyQueue[emergencyFront].destination << "\t";

cout << emergencyQueue[emergencyFront].numberOfPassengers << endl;

}

 

return 0;

117BOSTON
621NEW YORKCOLUMBUS 82
NORMAL
COLUMBUS 46
NORMAL
NORMAL
384L.A.
COLUMBUS127
NORMAL
17CHICAGO TAMPA
PRIORITY256CHICAGO COLUMBUS 34
984ATLANTA BUFFALO
19
NORMAL
10
NORMAL
112NEW YORKL.A.
321
NORMAL
96MILWAUKECOLUMBUS 41
SANDIEG0182
PRIORITY 99BOSTON
PRIORITY217ROCHESTRCINCINAT 81
NORMAL
NORMAL
180BOSTON
CHICAGO 164
542MONTREALCOLUMBUS101
NORMAL 641SANFRANSCOLUMBUS 75
PRIORITY321BALTIMORKANSASCT109
NORMAL
94SEATTLE COLUMBUS 86
NORMAL
600ST.LOUISDETROIT 100
PRIORITY510ØPORTLANDCOLUMBUS 8
151
COLUMBUS 97
RICHMOND 40
30
PRIORITY121NEWORLEABOSTON
PRIORITY386DENVER
PRIORITY682DENVER
PRIORITY998TORONTO PHOENIX
NORMAL
82DAYTON
COLUMBUS190
Transcribed Image Text:117BOSTON 621NEW YORKCOLUMBUS 82 NORMAL COLUMBUS 46 NORMAL NORMAL 384L.A. COLUMBUS127 NORMAL 17CHICAGO TAMPA PRIORITY256CHICAGO COLUMBUS 34 984ATLANTA BUFFALO 19 NORMAL 10 NORMAL 112NEW YORKL.A. 321 NORMAL 96MILWAUKECOLUMBUS 41 SANDIEG0182 PRIORITY 99BOSTON PRIORITY217ROCHESTRCINCINAT 81 NORMAL NORMAL 180BOSTON CHICAGO 164 542MONTREALCOLUMBUS101 NORMAL 641SANFRANSCOLUMBUS 75 PRIORITY321BALTIMORKANSASCT109 NORMAL 94SEATTLE COLUMBUS 86 NORMAL 600ST.LOUISDETROIT 100 PRIORITY510ØPORTLANDCOLUMBUS 8 151 COLUMBUS 97 RICHMOND 40 30 PRIORITY121NEWORLEABOSTON PRIORITY386DENVER PRIORITY682DENVER PRIORITY998TORONTO PHOENIX NORMAL 82DAYTON COLUMBUS190
Expert Solution
steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
Methods of StringBuilder 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
  • SEE MORE 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