Question

In C++. Write a program that can be used to assign seats for a commercial airplane...

In C++.

Write a program that can be used to assign seats for a commercial airplane and print out the ticket total. The airplane has 13 rows, with row 7 being the Emergency Exit row. Each row has 7 seats, there are two seats on each side of the plane and three seats in the middle with aisles on both sides. Rows 1 and 2 are considered first class with tickets for this specific  flight being $872.00 round trip. Rows 3 - 6 are business class with tickets at $697.60, and rows 7 through 13 are economy class with tickets at $436.00, however Emergency Exit row seats have an extra fee of $32.00 and passengers purchasing those seats must confirm that they are 16 years of age or older. Your program must prompt the user to enter the following information:

a. Ticket type (first class, business class, or economy; keep in mind the special circumstances for emergency row seats)

b. Desired seat(s)

Once all seats are selected there should be a 9% tax and the total should be displayed to the user.

Output the seating plan in the following form:

A B | C D E | E F
ROW 1 * X | * * * | X X
ROW 2 * X | * X * | * *
ROW 3 * * | X X X | * *
ROW 4 X X | * * * | X *
ROW 5 * X | * * X | * *
ROW 6 * X | * * * | X *
ROW 7 * * | * * * | * *
ROW 8 * X | * * X | X *
ROW 9 X * | * * * | X X
ROW 10 * X | * * X | * *
ROW 11 X X | * * * | * X
ROW 12 * * | X * X | * *
ROW 13 * * | * * * | * X

Here the * indicates that a seat is available; X indicates that the seat is occupied; | indicates the aisle of the plane. Make this a menu-driven program; show the user's choices (this is your starting seats, so make sure that seats already taken remain taken) and allow the user to make the appropriate selection of seats.

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

Complete C++ code:

#include<iostream>

#include<cctype>

#include<iomanip>

using namespace std;

void getData(char& ticketType, int& row,

char& column, double& total);

void printForm(char form[][7], int row, char column);

int main()

{

char ch, ticketType, column;

int row;

char form[13][7];

double total = 0;

// fill forums with *'s

for (int i = 0; i < 13; ++i)

for (int j = 0; j < 7; ++j)

form[i][j] = '*';

  

ch = 'Y';

while(ch == 'Y')

{

getData(ticketType, row, column, total);

printForm(form, row, column);

  

cout << "Do you want to book additional seat? Y/y for yes, N/n for no." << endl;

cin >> ch;

ch = static_cast<char>(toupper(ch));

if(ch == 'N') {

double tax = total*0.09;

cout << "Total amount: " << total << "$" << endl;

cout << "Tax amount: " << tax << "$" << endl;

cout << "Grand total: " <<total+tax << "$" << endl;

return 0;

}

}// end while

system("PAUSE");

return 0;

}

void getData(char& ticketType, int& row, char& column, double & total)

{

char ageConfirm;

cout << "The airplane has 13 rows, with six seats in each row. " << endl;

  

cout << "Enter ticket type,\n"

<< "F for first class, \n"

<< "B for business class,\n"

<< "E for economy class:" << endl;

cin >> ticketType;

ticketType = static_cast<char>(toupper(ticketType));

while(ticketType != 'F' && ticketType != 'B' && ticketType != 'E')

{

cout << "Invalid ticket type." << endl;

cout << "Enter ticket type,\n"

<< "F/f for first class, \n"

<< "B/b for business class,\n"

<< "E/e for economy class:" << endl;

cin >> ticketType;

ticketType = static_cast<char>(toupper(ticketType));

}   

switch(ticketType)

{

case 'F':

cout << "Row 1 and 2 are first class,\n" ;

cout << "Enter the row number you want to sit: " << endl ;

cin >> row;

while(row != 1 && row != 2) {

cout << "Invalid row entered" << endl;

cout << "Only Row 1 and 2 are for first class, enter accoringly!" << endl;

cin >> row;

}

total += 872;

break;

case 'B':

cout << "Row 3 throuh 7 are business class,\n";

cout << "Enter the row number you want to sit: " << endl ;

cin >> row;

if(row == 7) {

cout << "Is your age 16 or above? Y/N" << endl;

cin >> ageConfirm;

ageConfirm = static_cast<char>(toupper(ageConfirm));

if(ageConfirm == 'N') {

row = 0;

} else {

//additional charge

total += 32;

}

}

while(row < 3 || row > 7) {

cout << "Invalid row entered" << endl;

cout << "Only Row 3 through 7 are for business class, enter accoringly!" << endl;

cin >> row;

if(row == 7) {

cout << "Is your age 16 or above? Y/N" << endl;

cin >> ageConfirm;

ageConfirm = static_cast<char>(toupper(ageConfirm));

if(ageConfirm == 'N') {

row = 0;

} else {

//additional charge

total += 32;

}

}

}

total += 697.60;

break;

case 'E':

cout << "Row 8 through 13 are economy class." << endl;

cout << "Enter the row number you want to sit: " << endl ;

cin >> row;

while(row < 8 || row > 13) {

cout << "Invalid row entered" << endl;

cout << "Only Row 8 through 13 are for economic class, enter accoringly!" << endl;

cin >> row;

}

total += 436;

break;

}// end switch

cout << "Enter the seat number (from A to G). " << endl;

cin >> column;

column = static_cast<char>(toupper(column));

while(column < 'A' || column > 'G') {

cout << "Invalid choice!\nEnter the seat number (from A to G). " << endl;

cin >> column;

column = static_cast<char>(toupper(column));

}

}   

void printForm(char form[][7], int row, char column)

{

int i, j;

// update form

while((form[row - 1][column - 65] == 'X') || column < 'A' || column > 'G') {

cout << "Seat is already occupied or you have entered a invalid choice! Please select unoccupied and valid seat in the same row" << endl;

cin >> column;

column = static_cast<char>(toupper(column));

}

form[row - 1][column - 65] = 'X';

  

cout << "* indicates that the seat is available; " << endl;

cout << "X indicates that the seat is occupied. " << endl;

cout << setw(12) << "A" << setw(6) << "B" << setw(6) << "C"

<< setw(6) << "D" << setw(6) << "E" << setw(6) << "F" << setw(6) << "G" << endl;

  

  

// print form   

for(i = 0; i < 13; i++)

{

cout << left << setw(3) << "Row " << setw(2)<< i+1 ;

for(j = 0; j < 7; j++)

{

cout << right << setw(6) << form[i][j];

}

cout << endl;  

}   

}

Sample output:

The airplane has 13 rows, with six seats in each row.
Enter ticket type,
F for first class,
B for business class,
E for economy class:
F
Row 1 and 2 are first class,
Enter the row number you want to sit:
2
Enter the seat number (from A to G).
F
* indicates that the seat is available;
X indicates that the seat is occupied.
A B C D E F G
Row 1 * * * * * * *
Row 2 * * * * * X *
Row 3 * * * * * * *
Row 4 * * * * * * *
Row 5 * * * * * * *
Row 6 * * * * * * *
Row 7 * * * * * * *
Row 8 * * * * * * *
Row 9 * * * * * * *
Row 10 * * * * * * *
Row 11 * * * * * * *
Row 12 * * * * * * *
Row 13 * * * * * * *
Do you want to book additional seat? Y/y for yes, N/n for no.
y
The airplane has 13 rows, with six seats in each row.
Enter ticket type,
F for first class,
B for business class,
E for economy class:
B
Row 3 throuh 7 are business class,
Enter the row number you want to sit:
7
Is your age 16 or above? Y/N
N
Invalid row entered
Only Row 3 through 7 are for business class, enter accoringly!
7
Is your age 16 or above? Y/N
Y
Enter the seat number (from A to G).
A
* indicates that the seat is available;
X indicates that the seat is occupied.
A B C D E F G
Row 1 * * * * * * *
Row 2 * * * * * X *
Row 3 * * * * * * *
Row 4 * * * * * * *
Row 5 * * * * * * *
Row 6 * * * * * * *
Row 7 X * * * * * *
Row 8 * * * * * * *
Row 9 * * * * * * *
Row 10 * * * * * * *
Row 11 * * * * * * *
Row 12 * * * * * * *
Row 13 * * * * * * *
Do you want to book additional seat? Y/y for yes, N/n for no.
n
Total amount: 1601.6$
Tax amount: 144.144$
Grand total: 1745.74$

Add a comment
Know the answer?
Add Answer to:
In C++. Write a program that can be used to assign seats for a commercial airplane...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • For c++ Write a program that can be used to assign seats for a commercial airplane....

    For c++ Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, and rows 8 rows through 13 are economy class. Your program must prompt the user to enter the following information: Ticket type (first class, business class, or economy class) Desired seat a. b. Output the seating plan in the...

  • Java program for an Airplane Seating Reservation.

    Need help with this, please!Write a java program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats in each row. Rows 1 and 2 are first class, rows3 to 7 are business class, and rows 8 to 13 are economy class. Your program prompts the user to enter the following information:- Ticket type (first class or economy class)- For economy class, the smoking or non-smoking section- Desired seatOutput the seating...

  • The Course Project can be started in Week 7 and is due by 11:59 pm CT...

    The Course Project can be started in Week 7 and is due by 11:59 pm CT Saturday of Week 8. It must follow standard code formatting and have a comment block at the top of the code file with a detailed description of what the program does. Functions must have a comment block with a detailed description of what it does. Pseudocode must be provided in the comment block at the top of the file. This program will allow the...

  • I have to write a C program to assign seats on each flight of the airline’s...

    I have to write a C program to assign seats on each flight of the airline’s only plane (capacity: 40 seats, in 10 rows). For the sake of simplicity, assume that each row has 4 seats labeled A, B, C, D. Your program should display the following menu of alternatives: Please type 1 for "first class" Please type 2 for "business class" Please type 3 for “economy class”. If the person types 1, then your program should assign a seat...

  • Write a program in C to assign seats of a movie theater (capacity: 200 seats). Your...

    Write a program in C to assign seats of a movie theater (capacity: 200 seats). Your program should display the following menu of alternatives: Please type 1 for "section A, $50/ticket" type 2 for "section B, $70/ticket", and type 3 for "section C, $80/ticket".  If the user types 1, then your program should assign a seat in the A section (seats 1–50). If the user types 2, then your program should assign a seat in the B section (seats 51–100). If...

  • Can you help us!! Thank you! C++ Write a program that can be used by a...

    Can you help us!! Thank you! C++ Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...

  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

  • Labs CSIT 210 Introduction to Programming LAB 9B Arrays Change the program AirlineDriver.java to assign passenger seats in an airplane. Chesapeake Airlines is a small commuter airline with seats for...

    Labs CSIT 210 Introduction to Programming LAB 9B Arrays Change the program AirlineDriver.java to assign passenger seats in an airplane. Chesapeake Airlines is a small commuter airline with seats for 20 passengers in 5 rows of 4 seats each. Here is the layout: 1ABCD 2ABCD 3ABCD 4ABCD 5ABCD The user enters the row (1 – 5) and the seat (A – D). The seat entry may be lowercase. Use this code to enter the seat: System.out.print(" Enter row and seat...

  • Hello, I am working on a project for my C++ class, I have the vast majority...

    Hello, I am working on a project for my C++ class, I have the vast majority of the code figured out but am running into a few issues. Mainly updating each * to an X. The problem is as follows:(Airplane Seating Assignment) Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business...

  • The language is C++ for visual studio express 2013 for windows create a TicketManager class and...

    The language is C++ for visual studio express 2013 for windows create a TicketManager class and a program that uses the class to sell tickets for a performance at a theater. Here are all the specs. This is an intense program, please follow all instructions carefully. -I am only creating the client program that uses the class and all it's functions -The client program is a menu-driven program that provides the user with box office options for a theater and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT