Fortran 90 Coding Help

Recommended Posts

This programming exercise involves writing software to help with the task of

timetabling courses for a fictitious university. The mathematics department at

UWGC offers 24 modules with codes A1..A8; B1..B8 and C1..C8. It has five

classrooms for its exclusive use: rooms 1 and 2 have 20 seats, room 3 has 30 and

rooms 4 and 5 can each take 50 students. Classes can be scheduled to begin on

the hour from 9.00 till 16.00 each day of the week (except Wednesday when the

last class is at 12.00).

The timetabler needs software to perform the following tasks:

â€¢ to print the current state of the timetable

â€¢ to answer a query about the usage of a given slot (i.e. room, day and time)

â€¢ to list which rooms are free at a given day and time

â€¢ to list the timetabled hours for any given course

â€¢ to allow the current state of the timetable to be changed by adding a module

code in a free timetable slot and/or deleting a course from an existing slot

When adding a module code in a slot, the software must check that the slot is actually

free and also make some tests on room size and possible timetable clashes.

(i) All â€™Aâ€™ classes have 25 students

(ii) Classes B1..B6 have 15 students while B7 and B8 have 35

(iii) All â€™Câ€™ classes have at most 10 students

(iv) Courses B7 and B8 cannot run simultaneously

If the timetabler attempts to schedule a class which violates one or more of these

rules, the software should not accept it and print a warning message instead.

The software is to be menu-driven â€“ that is, it should offer choices

Display a timetable (1)

Check a timetable slot (2)

Check free rooms at a given day and time (3)

Check timetabled slots for a given course (4)

Release a slot (5)

Allocate a slot (6)

Your solution must be implemented in terms of two-dimensional arrays. That is the variable mon (i,j)

should hold the module code of the class to be held on a Monday in room i( 1 < i < 5) at time j(9<j<16)

(If no class is scheduled then mon(i,j) could have a default value such as â€™--â€™.)

Your solution must use function subprograms and/or subroutines â€“ i.e., it is not to

consist of a single main program. For instance, the tests on room size ((i) - (iii),

The code must include comments which help a user understand

how to work with the software. In addition to your code you must hand in sample

output listings which show that you have tested all the features of the program.

It is advisable to build your software solution in stages â€“ that is, to write and test

the program and subprograms for displaying the current timetable; then to add

(and test) further code for checking usage of a particular slot; and so on for all

My current coding

FUNCTION room_ok(K, M)

INTEGER :: K ! room number

CHARACTER(LEN=2) :: M ! module code

LOGICAL :: room_ok

! room_ok is returned as T if the number of seats in room K

! does not exceed the number of students on module M

! Otherwise it is returned as F

PROGRAM timetable

IMPLICIT NONE

CHARACTER(LEN=2), DIMENSION(1:5,9:16) :: mon, tue, wed, thu, fri

INTEGER, DIMENSION(1:5) :: roomsize

CHARACTER(LEN=2) :: mc

CHARACTER(LEN=3) :: day

INTEGER :: choice, room, hour

! Initialise room data

roomsize(1) = 20; roomsize(2) = 20; roomsize(3) = 30

roomsize(4) = 50; roomsize(5) = 50

! Initialise empty timetable

mon = â€™--â€™; tue = â€™--â€™; wed = â€™--â€™; thu = â€™--â€™; fri = â€™--â€™

! non-trivial entries for testing

mon(2,10) = â€™A4â€™; tue(3,12) = â€™A4â€™; wed(4,16) = â€™B6â€™

DO

SELECT CASE (choice)

CASE (1) ! Prints timetable for one day

PRINT"(â€™Which day (Mon - Fri)?â€™)": READ*,day

CALL Print_day(day)

...

CONTAINS

SUBROUTINE Menu ! prints option choices

PRINT"(/,â€™**** UWGC Timetable wizard ****â€™)"

PRINT"(â€™OPTIONS:â€™)"

PRINT"(â€™Display a timetable (1)â€™)"

PRINT"(â€™Check a timetable slot (2)â€™)"

PRINT"(â€™Check free rooms at a given day and time (3)â€™)"

PRINT"(â€™Check timetabled slots for a given course (4)â€™)"

PRINT"(â€™Release a slot (5)â€™)"

PRINT"(â€™Allocate a slot (6)â€™)"

SUBROUTINE Print_day(day) ! Prints timetable for day specified

CHARACTER(LEN=3), INTENT(in) :: day

SELECT CASE(day)

CASE(â€™Monâ€™)

CALL Print_times(mon)

CASE(â€™Tueâ€™)

CALL Print_times(tue)

CASE(â€™Wedâ€™)

CALL Print_times(wed)

CASE(â€™Thuâ€™)

CALL Print_times(thu)

CASE(â€™Friâ€™)

CALL Print_times(fri)

CASE default

PRINT"(â€™Invalid day!â€™)"

END SELECT

END SUBROUTINE Print_day

Any help with the rest of the coding is appreciated, having difficulty from this point on.

Share on other sites

....

I... hmm.....

Are you posting from 1972? Wait, no, you specified Fortran 90.... Huh. Parallel universe?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.