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 1
SC10032023/24 Sem 2 Assignment
The NTU Express Train consists of one train with a seating capacity of 5. It makes one trip
monthly. You are required to write a seating reservation program. You may use an array of 5
structures for building the program. Each structure should hold: (1) a seat number that has a
value between 1 and 5; (2) a marker (status) that indicates whether the seat is assigned (e.g.,
EMPTY or OCCUPIED); and (3) 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 40 characters long.
The program should display a menu to support the following functions:
(1) 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".
(2) 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 (i.e.5)
during seat assignment.
The program should issue the message Please enter a seat number between 1 and
5 if the selected seat number is not between 1 and 5.
(3) 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 1 and
5 if the selected seat number is not between 1 and 5.
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 2
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:
1: listOccupiedSeat()
2: assignSeat()
3: removeSeat()
4: quit
Enter your choice:
1
listOccupiedSeat():
The seat assignment list is empty
Enter your choice:
2
assignSeat():
Enter the seat number:
1
Enter customer name:
SC Hui
The seat has been assigned successfully
Enter your choice:
1
listOccupiedSeat():
Customer name: SC Hui
Seat number: 1
Enter your choice:
4
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 1- listOccupiedSeat (empty list condition)
Input Output
1
4
NTU EXPRESS TRAIN RESERVATION SYSTEM:
1: listOccupiedSeat()
2: assignSeat()
3: removeSeat()
4: quit
Enter your choice:
listOccupiedSeat():
The seat assignment list is empty
Enter your choice:
Page 3
Case 2 assignSeat (2 seats)+ listOccupiedSeat
2
1
SC Name1
2
2
PC Name2
1
4
NTU EXPRESS TRAIN RESERVATION SYSTEM:
1: listOccupiedSeat()
2: assignSeat()
3: removeSeat()
4: 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 Name1
Seat number: 1
Customer name: PC Name2
Seat number: 2
Enter your choice:
Case 3 assignSeat (invalid seat number condition)
2
11
12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!