Code:
#include <iostream>
#include<string>
#include<fstream>
using namespace std;
void menu();
void seatReserve();
void emptyRow();
void emptyPlane();
const int NUM_ROWS = 15;
const int NUM_SEATS = 6;
int seats[NUM_ROWS][NUM_SEATS] = { 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0};
double prices[NUM_ROWS][NUM_SEATS];
int main
{
cout << "Welcome to the aircraft inventory tool\n";
menu();
return 0;
}
void menu()
{
cout << "Please select an option from the following menu:\n"
<< "1 - Reserve a seat\n"
<< "2 - Display total seats sold\n"
<< "3 - Display total seats empty in a row\n"
<< "4 - Display total seats empty on the plane\n"
<< "5 - Display total amount in sales\n";
cin >> choice;
if (choice == 1)
seatReserve();
//else if (choice == 2)
//seatsSold();
else if (choice == 3)
emptyRow();
else if (choice == 4)
emptyPlane();
//else if (choice == 5)
//amountSales();
}
void seatReserve()
{
int row,col, seat;
cout << "Please enter the seat row and number you would like to reserve in this format\n"
<< "1 5\n"
<< "Please keep in mind that that the first 5 rows are first class and are the most expensive and olny have 4 seats and the second 5 rows are more expensive than the last 5\n";
cin >> row,col;
while (row <= 5 && col > 4)
{
cout << "That is not a valid seat number\n";
cin >> row, col;
}
seat = seats[row][col]
while (seat == 1)
{
cout << "We are sorry, that seat is already taken, please selct another\n";
cin >> row, col;
seat = seats[row][col];
}
cout << "Your seat has been reserved\n";
seat = 1;
menu();
}
void emptyRow()
{
int row, rowEmpty;
cout << "Please enter the row that you need the empty seat count for:\n";
cin >> row;
if (row <= 5)
{
for ( int rowPlus = 0; rowPlus < NUM_SEATS; rowPlus++)
rowEmpty += seats[row][rowPlus]
rowEmpty = 4 - rowEmpty
}
if (row <= 15 && row > 5)
{
for ( int rowPlus = 0; rowPlus < NUM_SEATS; rowPlus++)
rowEmpty += seats[row][rowPlus]
rowEmpty = 6 - rowEmpty
}
cout << "That row has " << rowEmpty << " empty seats\n";
}
void emptyPlane()
{
int planeEmpty;
for ( int row = 0; row < NUM_ROWS; row++)
{
for (int col =0; col < NUM_SEATS; col++)
planeEmpty += seats[row][col]
}
planeEmpty = 80 - planeEmpty
cout << "The plane has " << planeEmpty << " empty seats\n";
}