The
OHS school is planning a ski trip for 40 students.
The
HOTEL for
the ski-trip has 4 beds in each room.
A list of
STUDENTS must be assigned to each room.
For example:
STUDENTS HOTEL------------------------------
aaa | 0
aaa eee iii
empty
bbb
| 1 bbb fff
jjj empty
ccc | 2
ccc ggg empty
empty
ddd | 3
ddd hhh empty
empty
eee
|----------------------------------
fff
ggg
hhh
iii
jjj
In this example there are 6 empty beds.
The program below assigns single students to beds.
(1) Run this program. Assign a few students to beds.
(2)
Find out what is defective in this program - specifically,
explain
why it CANNOT assign students as shown above.
(3) Fix the program so that it can be used to assign beds correctly.
(4)
Change the program so that it is ONLY POSSIBLE to assign a student
to an empty bed.
(5)
Add a new method called ROOMMATES. It inputs the name of a
student, searches for that student, and prints the names
of the other students in the same room.
(6) The program should automatically assign a room, according to this algorithm:
Copy all
the room numbers from ROOMS into the first column of HOTEL
Count down
the first column, placing a student in each room.
Go back to
the top of the list, and count down the second column
placing
a student in each room.
Continue through the
third and fourth columns.
Change the program so that it AUTOMATICALLY assigns rooms as described above.