Question: Page 1 SC 1 0 0 3 2 0 2 3 / 2 4 Sem 2 Assignment The NTU Express Train consists of one train
Page
SC Sem Assignment
The NTU Express Train consists of one train with a seating capacity of It makes one trip
monthly. You are required to write a seating reservation program. You may use an array of
structures for building the program. Each structure should hold: a seat number that has a
value between and ; a marker status that indicates whether the seat is assigned eg
EMPTY or OCCUPIED; and the customer name of the seat holder. The seat number must
be unique. Therefore, each structure will have a different seat number when it is created.
You may assume that the name of a customer is not more than characters long.
The program should display a menu to support the following functions:
listOccupiedSeat The function requirements are given below:
The function prints the list of seat assignments.
It prints the following message when it is executed: "listOccupiedSeat:
If all seats are empty, the function should display the message: "The seat
assignment list is empty".
assignSeat The function requirements are given below:
The function assigns a customer to a seat. It reads in the selected seat number and
customer name from user, and then assigns the seat accordingly.
It prints the following message when it is executed: "assignSeat:
After assignment, the message The seat has been assigned successfully should be
displayed.
The program should issue a message Occupied Please choose another seat if the
selected seat has been assigned to another customer already.
The program should issue the message The train is full if the train is full ie
during seat assignment.
The program should issue the message Please enter a seat number between and
if the selected seat number is not between and
removeSeat The function requirements are given below:
The function removes a seat assignment. It reads in the selected seat number from
user and then remove the assigned seat accordingly.
It prints the following message when it is executed: "removeSeat:
After seat removal, the message Removal is successful should be displayed.
During seat removal, the program should issue the message All the seats are
vacant if all the seats are empty.
If the selected seat is empty, the function should issue the message Empty Enter
another seat number for removal
The program should issue the message Please enter a seat number between and
if the selected seat number is not between and
You are required to write the program and the functions according to the program
requirements. Note that:
You should design the program and define the functions according to the
requirements please refer to the sample test cases for program implementation
Page
You only need to consider the requirements stated in the program specification, and
you do not need to implement any user input checking which is not stated in the
specification.
You may add any other supporting functions in the program if needed.
You may include any C library functions in your program if needed.
Sample test case are given below.
A sample program running session is given below please note that the input data are shown
in orange color:
NTU EXPRESS TRAIN RESERVATION SYSTEM:
: listOccupiedSeat
: assignSeat
: removeSeat
: quit
Enter your choice:
listOccupiedSeat:
The seat assignment list is empty
Enter your choice:
assignSeat:
Enter the seat number:
Enter customer name:
SC Hui
The seat has been assigned successfully
Enter your choice:
listOccupiedSeat:
Customer name: SC Hui
Seat number:
Enter your choice:
The sample test cases for the program are given for your implementation see below The
sample test cases are organized in the form of input and output data for the convenience of
your testing in APAS.
Sample Test Cases Pretest
Case listOccupiedSeat empty list condition
Input Output
NTU EXPRESS TRAIN RESERVATION SYSTEM:
: listOccupiedSeat
: assignSeat
: removeSeat
: quit
Enter your choice:
listOccupiedSeat:
The seat assignment list is empty
Enter your choice:
Page
Case assignSeat seats listOccupiedSeat
SC Name
PC Name
NTU EXPRESS TRAIN RESERVATION SYSTEM:
: listOccupiedSeat
: assignSeat
: removeSeat
: quit
Enter your choice:
assignSeat:
Enter the seat number:
Enter customer name:
The seat has been assigned successfully
Enter your choice:
assignSeat:
Enter the seat number:
Enter customer name:
The seat has been assigned successfully
Enter your choice:
listOccupiedSeat:
Customer name: SC Name
Seat number:
Customer name: PC Name
Seat number:
Enter your choice:
Case assignSeat invalid seat number condition
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
