Question
help with this program please Write a C++ program to assign passenger seats in an airplane. Chesapeake Airlines is a small commuter airline with seats
help with this program please
Write a C++ program to assign passenger seats in an airplane. Chesapeake Airlines is a small commuter airline with seats for 36 passengers in 9 rows of 4 seats each. See the sample display below for a layout of the plane.
The user enters the row (1 9) and the seat (A D). The program checks the array to see if the seat is available. An X in the array indicates the seat is not available.
If the seat is available, assign an X to that position in the array. If its unavailable, display a message to the passenger.
There are 3 ticket classes:
Row 1 = First Class
Rows 2-4 = Business Class
Rows 5-9 = Coach
*Note that the rows are 0-8 in the C++ program.
Use the classCtr array supplied in the header file to keep track of how many seats in each class are purchased.
Continue processing requests until the user enters -1 for row. After -1 is entered for the row, display number of seats sold.
percentage occupied.
sales report.
You need to include the following functions in your program.
Function to get the row and seat.
This function displays a prompt requesting the value for row. If -1 is not entered for the row, the function displays a prompt requesting the seat letter. The seat can be an upper or lowercase letter. Check how the toupper function works in Chapter Six (Display 6.9).
This function is a call-by-reference since it needs to supply main with two values. See the function declaration getData in the cpp file provided. Check Display 5.4 get_numbers function and Display 5-9 get_input function.
These two functions are call-by-value.
Function to display the plane layout using the layout array provided in the header file. See the function declaration displayPlane in the cpp file provided.
Function to display the Sales Report, using the classes, classCtr, and fares arrays provided.
Any additional functions that make the program more modular.
Header files
User-defined header files are useful for reducing redundant code. The array.h file contains all the arrays you need for this project. To incorporate these arrays into your cpp file, use a statement like this: #include "array.h"
The program has to know where this file is located. To add the header file: right-click on Header Files in the Solution Explorer of the IDE and add the header file to the project so you dont need to specify a drive.
The #include statement is basically like a copy/paste operation. The compiler will replace the #include line with the actual contents of the file you're including when it compiles the file. This way, any program that needs these arrays can include them instead of keying the array data in each program.
I have included 4 files to help you get started.
array 2Dem.cpp
//Two-Dimensional array // Display 7.14 #include using namespace std; const int ROW = 4, COL = 3; int main( ) { int grade[ROW][COL]; //Input grades by student for(int r = 0; r > grade[r][c]; } } coutairlines Arrays.cpp
#include #include #include using namespace std; #include "array.h" void displayPlane(char [ROW][COL]); void getData(int & , char & ); int main() { }arry,h
//arrays for airline problem const int ROW = 9; const int COL = 4; const int CTR = 3; //initial seats in the plane char layout[ROW][COL] = { { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }, { 'A', 'B', 'C', 'D' }}; int classCtr[CTR] = {0,0,0}; std::string classes[] = {"First Class", "Business Class", "Coach"}; double fare [] = {500, 300, 100};ser enters-1 for row. After -1 is entered for the n C D inter rou 1 to step) Total seats-7 Percent occupled 19.44 Seles Report Ticket Frice Total Sale Piret Clas 500.00 1 se0.a Business CL 38.0 6e.00 4 480.0e Coach 100.00 Total Sales -1588.00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started