Summer 2023 Final
Page 1
Final Exam
ESE 124/EEO 124 – programming Fundamentals
Summer 2023
Q1:[20pts]
Finding the Index of First Unique Character in a String
Q2:[40pts]
Use a stack to order a sequence of floating point numbers in increasing order of their values. The
values are read one by one from the keyboard. Every new number is saved in the stack. Numbers
are read until the user enters ‘#’. Then, the values stored in the stack are displayed in the desired
order.
Q3:[40pts]
A hotel manager has to process N advance bookings of rooms for Aug 2023. His hotel has C rooms. C is
a constant for the program. Bookings contain an arrival date and a departure date. The program should
solve the following requirements:
· All dates of the N advance bookings are read from an input file. The value of N is found on
the first line of the input file. The other lines include two values, one value for the arrival day
(e.g., 8052023) and one value for the departure day (e.g., 8092023). The first one or two digits of
a value represent the month, then two digits are for the day (i.e. 05 or 23), and 4 digits are for the
month. [ 10 points ]
· The information about arrival and departure date should be stored in an 1D array, where each
element of the array stores the two dates. Use a dynamic 1D array of size N. [ 10 points ]
· The hotel manager wants to find out whether there are enough rooms in the hotel to satisfy
the demand. Saved output file and display the dates that can be satisfied [ 10 points ] and the
dates that cannot be satisfied [ 10 points ].
Q3:
input data:
C: a number of the room
N: Advanced booking number from the input file (input.txt).
Page 2
input.txt (sample)
3
08142023 08152023
08112023 08252023
08012023 08152023
assume:
if C = 2
output file (output.txt)
Aug 1. Satisfied
Aug 2. Satisfied
…
Aug 14 unsatisfied
Aug 15 unsatisfied
Aug 16 satisfied
…
Aug 31 satisfied