Programming Assignment #1 CSC 36000 – Data Structures Programming Assignment # XXXXXXXXXXMulti-dimensional Arrays ? XXXXXXXXXXJanuary 17, 2020 SITUATION: Southern Comfort Airlines has asked you to...

1 answer below »
I need to complete a C++ project using multi-dimensional arrays...


Programming Assignment #1 CSC 36000 – Data Structures Programming Assignment #1 (Multi-dimensional Arrays ?) January 17, 2020 SITUATION: Southern Comfort Airlines has asked you to design a program that assigns seats to passengers on a "first-come, first serve" basis. Southern Comfort is a small commuter airline with service from Jackson, MS to several cities in other states. Each of their aircraft is a 30-passenger unit with a seating plan as shown below. Seats are numbered 1-1, 1-2, 1-3, 2-1, 2-2, .., 9-3, 10-1, 10-2, 10-3. Front 1 2 3 1 2 3 4 5 6 7 8 9 10 Rear The first three rows are designated as "First Class" and the last seven rows are designated "Coach". In assigning seats, you must abide by the following rules in the order shown: Rule 1 - Specific seat requests are honored first. Rule 2. If a requested seat is already assigned to another passenger, the person should be place in the same row, if possible, starting from the left side (lowest seat number.) (Note: a value of -999 is to be used to indicate a vacant seat.) Rule 3 - If the requested row is full, the passenger should be seated as far forward as possible in the requested column but within the requested section. THERE IS NO SWITCHING OF SECTIONS. Rule 4 - If the request using Rule 2 or Rule 3 cannot be honored, the passenger should be assigned the first available seat starting from the front and left of the requested section going across each row until a vacant seat is found. AGAIN, THERE IS NO SWITCHING OF SECTIONS BETWEEN SECTIONS. Rule 5 - First Class and Coach request must be honored. If there are no seats in the requested section, the passenger's Boarding Number must go on a "WAITING LIST" for the next flight. The Airline has 4 cities it services. The cities and their flight numbers are: Memphis, Tennessee 1010 Little Rock, Arkansas 1020 Shreveport , Louisiana 1030 Huntsville, Alabama 1040 Theses flights are from Jackson, Mississippi to the indicated city. Numbers for the return flights are the same except you add 5 to the appropriate number. For example, 1025 would be the flight number for the return flight from Little Rock to Jackson. CSC 36000 – Data Structures Programming Assignment #1 Page 2 PROBLEM STATEMENT: You are to write a program using the C++ programming language that assigns seats on the various flights according to the rules mentioned on the previous page. In so doing, you may use any programming construct with which you are familiar. ALL PROGRAMS MUST BE WELL DOCUMENTED AND MODULARIZED. (Hint, use a 3D array for the seating chart and eight single dimension arrays for the waiting lists or an array of structures in which the arrays are part of the structure. You can also use classes.) This program is due on January 31, 2020. INPUT: The input file for this program will consist of an unknown number of passenger records. Each record will be on one line and have the format of: Passenger's assigned Boarding Number, the Requested Flight Number, the Requested Section, the Requested Seat Row, and the Requested Seat Column. Both the Passenger's Boarding Number and the flight number will be four digit integers. The section requested will be indicated by a single character, F for First Class and C for Coach. This will be followed by the row number which will be between 1 and 10. The last item in each record will be another single character and will be one of the three possible values of L, M, or R which stand for Left Seat, Middle Seat, and Right Seat respectively. A typical line of data might look like this: 6723 1045 C 8 M You may assume all data is valid. A sentinel of a negative value for the passenger’s Boarding Number will indicate the end of the input file. The data file name is data1 . PROCESSING: All processing is to be completed according to the rules specified on the previous page. Process the data for one passenger BEFORE proceeding to the next passenger’s data. An initial value of –999 is to be assigned to all unoccupied seats. OUTPUT: Output for this program is to be in the form of a seating chart for each flight. Each chart must include the following: The name of the airline, the flight number, the city of departure, the city of destination, the actual seating chart, and the waiting list showing the passenger's boarding number. If there is no entry in the waiting list, the message " There is no waiting list for this flight " is to be printed in place of the actual waiting list. You DO NOT have to keep a separate Waiting List for First Class and Coach passengers. If you use one list, you can expect no more than 50 passengers. If you use separate waiting list for each section, you can expect no more than 30 passengers each. To save paper, print Waiting Lists in rows of 10 passengers each with 3 spaces between passenger numbers. After each seating chart has been printed, the message END OF SEATING CHART must appear. Each seating chart must appear on a separate page of output. See the example on the next page for guidance. DONOT PRINT THE DELIMITER SHOWN IN THE OUTPUT EXAMPLE. After the last seating chart has been printed, the message END OF PROGRAM OUTPUT is to be printed. CSC 36000 – Data Structures Programming Assignment #1 Page 3 Output example: Southern Comfort Airlines Flight 1010 FROM: Huntsville, Alabama TO: Memphis, Tennessee 5472 4426 2273 4345 3005 -999 3119 9892 1251 2900 3492 2274 5999 6651 8820 9928 5432 -999 5489 2395 2182 4442 6177 6232 -999 -999 -999 9132 7233 4434 WAITING LIST There is no waiting list for this flight. END OF SEATING CHART Southern Comfort Airlines Flight 1045 FROM: Huntsville, Alabama TO: Jackson, Mississippi 3482 7726 1283 2345 3345 7629 1119 9842 9991 2900 3492 2274 -999 6651 8820 9928 5432 -999 -999 2395 1182 4442 7177 1632 -999 -999 -999 9122 8233 1234 WAITING LIST 6699 5551 END OF SEATING CHART END OF PROGRAM OUTPUT First Class Seating Coach Seating A i s l e ---new page ------------new page--------------new page -------------new page-----------------new page -------------new page--------------new page --- 1004 1020 C 9 R 4031 1030 C 10 M 5041 1025 C 4 L 1007 1020 F 1 L 5042 1040 F 3 M 6051 1035 C 6 M 7142 1010 C 9 M 5121 1010 F 1 M 7061 1010 C 9 L 6130 1030 F 1 L 8154 1010 C 8 L 8071 1015 F 1 R 4032 1035 C 9 R 2169 1035 C 10 M 2218 1030 C 7 L 2168 1015 F 2 R 9111 1015 C 4 R 9110 1030 F 2 M 1001 1030 F 1 M 1219 1015 C 6 R 5043 1045 C 4 M 6052 1015 F 1 M 5122 1035 F 1 M 1003 1045 F 1 R 7062 1035 C 5 L 8155 1015 C 4 M 8072 1010 C 4 L 4033 1035 C 7 L 2153 1010 F 3 R 3167 1045 F 3 M 2018 1030 F 1 L 1101 1010 C 5 R 8156 1010 C 5 R 3157 1045 C 10 M 6053 1015 F 1 L 1002 1030 F 3 R 7143 1030 C 4 R 7063 1030 C 5 R 6186 1030 C 5 M 8073 1030 C 5 R 4034 1015 F 2 M 2017 1030 C 4 M 9109 1030 C 7 L 2016 1030 C 7 M 3220 1045 C 5 L 1102 1045 F 1 L 4159 1035 C 10 L 5045 1030 C 7 L 1005 1045 F 1 M 6054 1010 C 9 M 6131 1030 C 4 L 7064 1045 F 2 M 8160 1020 C 5 L 4161 1010 C 6 L 4035 1045 C 4 L 2162 1045 C 5 L 2019 1045 C 10 R 3163 1010 C 6 M 3021 1030 C 5 L 8164 1030 C 8 L 1006 1030 C 8 M 5046 1030 C 6 R 7144 1015 C 9 L 6055 1045 C 9 R 7065 1030 F 3 L 8074 1045 C 4 R 6165 1030 F 3 M 4036 1030 F 3 L 9108 1030 C 4 R 2011 1045 C 6 R 1103 1010 C 8 M 8158 1045 C 7 R 1008 1035 F 3 R 7166 1035 F 2 R 5047 1010 C 5 L 6132 1030 C 8 M 6056 1030 C 8 R 7066 1030 C 10 R 3174 1045 C 7 M 9081 1045 C 6 M 1010 1045 C 6 L 4037 1030 C 10 M 5185 1030 C 7 L 1104 1035 C 5 R 1009 1030 F 2 L 8159 1035 F 2 R 4184 1030 F 2 M 5048 1035 F 1 R 6133 1030 F 2 R 6057 1030 C 8 R 7067 1040 F 2 M 2015
Answered Same DayJan 18, 2021

Answer To: Programming Assignment #1 CSC 36000 – Data Structures Programming Assignment #...

Arun Shankar answered on Jan 22 2021
152 Votes
Solution with screenshots/data1.txt
6723 1045 C 8 M
2356 1020 F 2 L
Solution with screenshots/output_sc
reenshot_01.JPG
Solution with screenshots/output_screenshot_02.JPG
Solution with screenshots/program.cpp
#include
#include
#include
#include
#include
using namespace std;
typedef struct flight
{
int num;
int seats[10][3];
int wlist[100];
int wcount;
}flight;
/* This function prints the boarding pass for a
flight that it receieves as its argument. */
void print_boarding_pass(flight f)
{
char filname[255];
sprintf(filname, "%d", f.num);
FILE* fpOut = fopen(filname,"w");
fprintf(fpOut,"BOARDING PASS FOR FLIGHT %d\n----------------------------------\n",f.num);
fprintf(fpOut,"\n\n\n\n");
for(int i=0;i<10;i++)
{
for(int j=0;j<3;j++)
{
fprintf(fpOut,"%d\t",f.seats[i][j]);
}
fprintf(fpOut,"\n");
}
fprintf(fpOut,"\n\nWAITING LIST\n-------------------------\n\n");
// Print waiting list
for(int i=0;i ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here