Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The aim of this program is to read a seat chart of a small airplane stored in a

ID: 646778 • Letter: T

Question

The aim of this program is to read a seat chart of a small airplane stored in a file named

Explanation / Answer

#include #include #include #include #include using namespace std; //function declarations void init(); void menu(); void checkSeat(); void printTicket(); void displaySeating(); //global variables const int firstClassPrice = 10000; const int economyPrice = 5000; const int rows = 9; const int columns = 5; const int size = 50; char seat[rows][columns]; double price, discount; string type, sname, name[rows][columns]; bool answer; void init() { char letters[11] = "ABCDEFGHIJ"; char letter; /* while variable int row is smaller than our maximum amount of rows (10)*/ for ( int row = 0; row //assign the letter of the current row to letter variable; letter = letters[row]; //for every seat in a row for ( int column = 0; column //make seat['A'][0] for instance empty seat[letter][column] = '0'; } } } void menu() { { cout "Welcome to taxiflite.comn"; cout "Please choose one of the following:n "; cout "1. First Classn"; cout "2. Economyn"; cout "3. Seating allocationn"; cout "4. Ticket holdern"; } void checkSeat() { char cout "Enter name:"; cin >> sname; cout "Do you want a specific seat:(y/n) : "; cin >> reply; if( reply == 'y' ) { init(); cout "Enter seat: n"; cin >> seat[rows][columns]; if(seat[rows][columns] == 'X') { seat[rows][columns] = 'X'; name[rows][columns] = sname; } else { int x = rand()%rows; int y = rand()%columns; while(seat[x][y] == 'X'); { int x = rand()%rows; int y = rand()%columns; } seat[rows][columns] = 'X'; name[rows][columns] = sname; } } else { init(); int rows = rand()%rows; int columns = rand()%columns; while ( seat[rows][columns] = 'X') { int rows = rand()%rows; int columns = rand()%columns; } seat[rows][columns] = 'X'; name[rows][columns] = sname; } void printTicket() { cout "Name: " "Seat No: " "Ticket type: " "price: " void displaySeating() { } int main() { int choice; srand(time(NULL)); //need this for random numbers for ( int count = 0 ; count > choice; switch (choice) { case 1: type = "First class"; init(); int rows = 9; { checkSeat(); bool isleSeat1 = seat[rows][1]; bool isleSeat2 = seat[rows][2]; if ( isleSeat1 == true || isleSeat2 == true ) { discount = 10 / 100 * firstClassPrice; price = firstClassPrice - discount; } else { price = firstClassPrice; } } break; case 2: type = "Economy"; init(); while( rows > 2 ) { checkSeat(); bool isleSeat1 = seat[rows][1]; bool isleSeat2 = seat[rows][2]; if ( isleSeat1 == true || isleSeat2 == true ) { discount = 10 / 100 * firstClassPrice; price = firstClassPrice - discount; } else { price = firstClassPrice; } } break; case 3: printTicket(); break; case 4: default: cout "Incorrect. Choose between 1-4 n"; } } return 0; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote