Ravz Posted June 13, 2008 Report Share Posted June 13, 2008 This programming exercise involves writing software to help with the task oftimetabling courses for a fictitious university. The mathematics department atUWGC offers 24 modules with codes A1..A8; B1..B8 and C1..C8. It has fiveclassrooms for its exclusive use: rooms 1 and 2 have 20 seats, room 3 has 30 androoms 4 and 5 can each take 50 students. Classes can be scheduled to begin onthe hour from 9.00 till 16.00 each day of the week (except Wednesday when thelast 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 modulecode in a free timetable slot and/or deleting a course from an existing slotWhen adding a module code in a slot, the software must check that the slot is actuallyfree 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 simultaneouslyIf the timetabler attempts to schedule a class which violates one or more of theserules, the software should not accept it and print a warning message instead.The software is to be menu-driven – that is, it should offer choicesDisplay 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 toconsist of a single main program. For instance, the tests on room size ((i) - (iii),The code must include comments which help a user understandhow to work with the software. In addition to your code you must hand in sampleoutput 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 testthe 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 allmenu options.My current codingFUNCTION room_ok(K, M)INTEGER :: K ! room numberCHARACTER(LEN=2) :: M ! module codeLOGICAL :: 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 FPROGRAM timetableIMPLICIT NONECHARACTER(LEN=2), DIMENSION(1:5,9:16) :: mon, tue, wed, thu, friINTEGER, DIMENSION(1:5) :: roomsizeCHARACTER(LEN=2) :: mcCHARACTER(LEN=3) :: dayINTEGER :: choice, room, hour! Initialise room dataroomsize(1) = 20; roomsize(2) = 20; roomsize(3) = 30roomsize(4) = 50; roomsize(5) = 50! Initialise empty timetablemon = ’--’; tue = ’--’; wed = ’--’; thu = ’--’; fri = ’--’! non-trivial entries for testingmon(2,10) = ’A4’; tue(3,12) = ’A4’; wed(4,16) = ’B6’DOCALL MenuREAD*,choiceSELECT CASE (choice)CASE (1) ! Prints timetable for one dayPRINT"(’Which day (Mon - Fri)?’)": READ*,dayCALL Print_day(day)...CONTAINSSUBROUTINE Menu ! prints option choicesPRINT"(/,’**** 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)’)"END SUBROUTINE MenuSUBROUTINE Print_day(day) ! Prints timetable for day specifiedCHARACTER(LEN=3), INTENT(in) :: daySELECT 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 defaultPRINT"(’Invalid day!’)"END SELECTEND SUBROUTINE Print_dayAny help with the rest of the coding is appreciated, having difficulty from this point on. Quote Link to post Share on other sites
jcl Posted June 13, 2008 Report Share Posted June 13, 2008 ....I... hmm.....Are you posting from 1972? Wait, no, you specified Fortran 90.... Huh. Parallel universe? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.