all three pictures are parts of the question. please solve in c++
#include <iostream>
#include <string>
using namespace std;
class FlightBooking {
public:
static const int LIMIT = 105;
FlightBooking(int id, int capacity, int
reserved);
void printStatus();
bool reserveSeats(int number_ob_seats);
bool cancelReservations(int number_ob_seats);
private:
int id;
int capacity;
int reserved;
};
void FlightBooking::printStatus()
{
cout.precision(0);
double pers = (reserved*100./capacity);
cout << "Flight " << id << " : "
<< reserved << "/"
<< capacity << " ("
<< fixed << pers << "%) seats reserved" <<
endl;
}
FlightBooking::FlightBooking(int _id, int _capacity, int
_reserved)
{
id = _id;
double pers = _reserved * 100. / _capacity;
if(pers > LIMIT)
{
capacity = _capacity;
reserved = LIMIT * _capacity/
100;
}
else
{
capacity =
_capacity;
reserved =
_reserved;
}
}
bool FlightBooking::reserveSeats(int number_ob_seats)
{
if (((reserved + number_ob_seats)*100./capacity) >
LIMIT) {
cout << "Cannot perform this
operation" << endl;
return false;
}
reserved += number_ob_seats;
return true;
}
bool FlightBooking::cancelReservations(int number_ob_seats)
{
if(reserved - number_ob_seats >= 0)
{
reserved -= number_ob_seats;
return true;
}
cout << "Cannot perform this operation" <<
endl;
return false;
}
int main() {
int reserved = 0,
capacity = 0;
cout << "Provide flight capacity: ";
cin >> capacity;
cout << "Provide number of reserved seats:
";
cin >> reserved;
FlightBooking booking(1, capacity, reserved);
string command = "";
string quit = "quit";
while (command != quit)
{
booking.printStatus();
cout << "What would you like to do?: ";
cin >> command;
if(command == quit) break;
int number = 0;
cin >> number;
if(command == "add")
booking.reserveSeats(number);
if(command == "cancel")
booking.cancelReservations(number);
}
system("pause");
return 0;
}
Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...
Hello, I have some errors in my C++ code when I try to debug it. I tried to follow the requirements stated below: Code: // Linked.h #ifndef INTLINKEDQUEUE #define INTLINKEDQUEUE #include <iostream> usingnamespace std; class IntLinkedQueue { private: struct Node { int data; Node *next; }; Node *front; // -> first item Node *rear; // -> last item Node *p; // traversal position Node *pp ; // previous position int size; // number of elements in the queue public: IntLinkedQueue();...
In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits> #include <iostream> #include <string> // atoi #include <time.h> #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ const unsigned int DEFAULT_SIZE = 179; // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() {...
I have updated my previously posted C++ question to ensure that I have included all of the necessary documentation in order to complete Part 2 - Bank Account of the assigned lab in its entirety. Please note that the lab below is somewhat lengthy, and I do not expect you to answer each question! If coding the full lab is too much to ask, please focus soley on Part 2 of the lab, titled Bank Account and the subsections that...