COS1511 ASSIGNMENT 3 SOLUTIONS 2021 SEMEMSTER 1 AND
2
Solution:
#include <iostream>
#include <string>
using namespace std;
const int SEATS_ROWS = 9;
const int SEATS_COLS = 6;
const int TIMES_ROWS = 5;
const int TIMES_COLS = 2;
const int ECONOMY_CLASS = 1600;
string flightTimes[TIMES_ROWS][TIMES_COLS] = {"7.00", "9.30", "9.00", "11.30", "11.00",
"13.30","13.00","15.30","15.00","17.30"};
void displayAllSeats(string seatsArray[SEATS_ROWS][SEATS_COLS], int
bookedSeats[SEATS_ROWS][SEATS_COLS])
{
for(int i = 0; i < SEATS_ROWS; i++)
{
if(i == 4)
cout << "Economy class " << ECONOMY_CLASS << endl;
for(int j = 0; j < SEATS_COLS; j++)
{
if(seatsArray[i][j] != "")
{
if(bookedSeats[i][j] == 1)
cout << "|**";
else
cout << "|"<< seatsArray[i][j];
if(j == 2)
cout << "----";
}
}
cout << "|" << endl;
2
Solution:
#include <iostream>
#include <string>
using namespace std;
const int SEATS_ROWS = 9;
const int SEATS_COLS = 6;
const int TIMES_ROWS = 5;
const int TIMES_COLS = 2;
const int ECONOMY_CLASS = 1600;
string flightTimes[TIMES_ROWS][TIMES_COLS] = {"7.00", "9.30", "9.00", "11.30", "11.00",
"13.30","13.00","15.30","15.00","17.30"};
void displayAllSeats(string seatsArray[SEATS_ROWS][SEATS_COLS], int
bookedSeats[SEATS_ROWS][SEATS_COLS])
{
for(int i = 0; i < SEATS_ROWS; i++)
{
if(i == 4)
cout << "Economy class " << ECONOMY_CLASS << endl;
for(int j = 0; j < SEATS_COLS; j++)
{
if(seatsArray[i][j] != "")
{
if(bookedSeats[i][j] == 1)
cout << "|**";
else
cout << "|"<< seatsArray[i][j];
if(j == 2)
cout << "----";
}
}
cout << "|" << endl;