Question Details

Answered: - are you online i need help completing this Project Four - Airline


are you online i need help completing this?

Project Four - Airline ProblemWrite a C++ program to assign passenger seats in an airplane. Chesapeake Airlines is a smallcommuter airline with seats for 36 passengers in 9 rows of 4 seats each. See the sample displaybelow 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 theseat 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 it?s unavailable, display amessage to the passenger.There are 3 ticket classes:Row 1 = First ClassRows 2-4 = Business ClassRows 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 classare 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.? Page 2You 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, thefunction 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.I have included 2 files to help you get started.airlineArrays.cpp file - Use this file for your program statements.#include#include#include using namespace std;#include "f:\array.h"void displayPlane(char [ROW][COL]);void getData(int & , char & );int main(){}? Page 3array.h file ? This file contains the arrays needed for this project.//arrays for airline problemconst int ROW = 9;const int COL = 4;const int CTR = 3;//initial seats in the planechar 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};string classes[] = {"First Class", "Business Class", "Coach"};double fare [] = {500, 300, 100};Header filesUser-defined header files are useful for reducing redundant code. The array.h file contains all the arraysyou need for this project. To incorporate these arrays into your cpp file, use a statement like this:#include "f:\array.h"The f:\ is in the string because I saved this file in the root directory of my flash drive. The program hasto know where this file is located so adjust the drive for your storage. You may also right-click onHeader Files in the Solution Explorer of the IDE and add the header file to the project so you don?t needto specify the drive.The #include statement is basically like a copy/paste operation. The compiler will replace the #includeline with the actual contents of the file you're including when it compiles the file. This way, anyprogram that needs these arrays can include them instead of keying the array data in each program.? Page 4Develop C++ program with the following new features:o Arrayso Arrays and functionso Call-by-reference functionso User defined header files.?Advice from the Instructor:o As usual, code this problem in small steps, one function at a time.o In main, the row and seat values need to be converted to indices for the plane layout array.The row value needs to be converted to a legal index from 0 to 8.You can use one statement to adjust the row index.The seat letter needs to be converted to a legal index from 0 to 3. Consider subtracting theASCII value 65 from the value of the seat entered to change the index. It only takes onestatement to adjust the column index using this technique.For example: A ? 65 = 0o The advantage of arrays is the same in C++ as in Java - often reducing the amount ofcode you need. First make sure your program works correctly and then go back and seeif you can write the code more efficiently. For example the function to write the salesreport can contain one for loop that produces the 3 line items in the report as welltotaling total sales.Do not use code like this:Total = classCtr[0] + classCtr[1] + classCtr[2];Use the power of indexing through an array with a for loop.Use your Java array experience to code this problem


#include<iostream>

 

#include<string>

 

#include<iomanip>

 

#include "array.h"

 

using namespace std;

 

// constant values

 

int row, seat;

 

int occupiedSeat;

 

float totaSeat;

 

// list of functions

 

void displayPlane(char layout[ROW][COL]);

 

void getData(int &, char &);

 

void displayReport();

 

int main() {

 

char seatChar;

 

// call function to getSeats (which will also displayPlane)

 

cout << "Enter row (-1 to stop>) ";

 

cin >> row;

 

while (row != -1) {

 

displayPlane(layout);

 

getData(seat, seatChar);

 

if (layout[row - 1][seat] != 'X') {

 

if (row == 1) {

 

classCtr[0] += 1;

 

}

 

else if (row >= 2 && row <= 4) {

 

classCtr[1] += 1;

 

}

 

else {

 

classCtr[2] += 1;

 

}

 

layout[row - 1][seat] = 'X';

 

occupiedSeat++;

 

}

 

cout << "Enter row (-1 to stop>) ";

 

cin >> row;

 

}

 

displayPlane(layout);

 

cout << "\tTotal Seats = " << occupiedSeat << endl;

 

totaSeat = (float)occupiedSeat / 36.0;

 

cout << "\tPercent occupied = " << ((totaSeat)* 100.00) << endl;

 

displayReport();

 

return 0;

 

}

 

/**

 

*

 

*/

 

void getData(int &seat, char &seatChar) {

 

cout << "Enter the seat (A ? D): ";

 

cin >> seatChar;

 

seat = toupper(seatChar) - 65;

 

}

 

/**

 

*

 

*/

 


 

void displayPlane(char layout[ROW][COL]) {

 

cout << endl;

 

cout << "\tChesapeake Airlines " << endl << endl;

 

for (int row = 0; row < ROW; row++) {

 

cout << (row + 1) << "\t";

 

for (int col = 0; col < COL; col++) {

 

cout << layout[row][col] << "\t";

 

}

 

cout << endl;

 

}

 

}

 

void displayReport() {

 

double sale = 0;

 

double totalSale = 0;

 

cout << "\n\t\t\t\tSales Report" << endl;

 

cout << "\t\t\tTicket Price\t\tTotal Sales" << endl;

 

for (int i = 0; i < 3; i++) {

 

sale = classCtr[i] * fare[i];

 

cout << setprecision(2) << fixed << setw(15) << classes[i] <<

 

setw(15) << fare[i] << setw(20)

 

<< classCtr[i] << " " << sale << endl;

 

totalSale += sale;

 

}

 

cout << endl;

 

cout << setprecision(2) << fixed << "Total Sales = " << totalSale << endl;

 

}

 


 

 


Solution details:

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Oct 07, 2020

EXPERT

Tutor

ANSWER RATING

GET INSTANT HELP/h4>

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now