Skip to main content

Passenger Seats Assigning Program full implementation in C++ - HJ Soft

Description:

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 it’s 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 the 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 the 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.


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 "f:\\array.h"
The f:\\ is in the string because I saved this file in the root directory of my flash drive. The program has to know where this file is located so adjust the drive for your storage. You may also right-click on Header Files in the Solution Explorer of the IDE and add the header file to the project so you don’t need to specify the 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.

Develop C++ program with the following new features:

Arrays
Arrays and functions
Call-by-reference functions
User-defined header files.

Advice from the Instructor:
As usual, code this problem in small steps, one function at a time.
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 the ASCII value 65 from the value of the seat entered to change the index. It only takes one statement to adjust the column index using this technique.

For example: A – 65 = 0

o The advantage of arrays is the same in C++ as in Java - often reducing the amount of code you need. First, make sure your program works correctly and then go back and see if you can write the code more efficiently. For example, the function to write the sales report can contain one for loop that produces the 3 line items in the report as well totaling total sales.

Do not use code like this:
Total = classCtr[0] + classCtr[1] + classCtr[2];

Output Screenshot:


Buy now

CONTACT DETAILS

For any other questions or other tasks please feel free to contact me
via email: mhassnainjamil@gmail.com
via WhatsApp: +92-324-7042178
via skype: hassnainjamil1

Comments

Popular posts from this blog

The Zoo Management System - entity relationship diagram & MS Access Database

Zoo Management System - Project Details: You are the employee of a big, worldwide working Zoo Management Company. Your company is responsible for the Zoo management. Your boss thinks it would be a great idea to store all data for each Zoo in a brand new self-developed ZOO Management System. Up to now, the ZOO management company has maps of each ZOO available. Your boss knows that you took a course in introduction on an ERP system, so he asks you if you could help designing such a system. Each ZOO must have the same organizational structure, which should look like this: Each Zoo has a Zoo-Address. Each Zoo has many visitors (Visitor Ticket Process (VTP). Many Zoo-Attractions belong to a Zoo. Module 1: Entity Relationship Diagram Design a ER (entity-relationship) diagram for your ZOO Management System. Use the information provided below with the entities and its attributes. Put the entities in the correct relationship to each other (organizational structure). Module 2: DB Implem...

Human Physiology by Stuart Ira Fox [PDF] (12th edition) free download

Sudoku Game Project in Java with full source code including GUI task

Introduction The purpose of the project is to try in practice the use of recursion and object-oriented program design. Please make sure to read this entire note before starting your work. Pay close attention to the sections on deadlines, deliverables, and exam rules. The problem Your task in this part of the project is to write a solver for Sudoku puzzles. Sudoku puzzles are a kind of crossword puzzles with numbers where the following two conditions have to be met: In each row or column, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they must all be different.  For each of the nine non-overlapping 3x3 blocks, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they ust all be different. The following two figures show a Sudoku puzzle and its solution. The input The input of your program, the Sudoku puzzles, is given in text files. More specifically, they are represented as nine lines of nine characters separated by spaces. The characters can be of two...