Sample answer for ACOM1900 c/w 2, 2007-8 Roy Ruddle, February 2008 =================pseudocode (30 marks in total; NB: for good marks, s/w needs to include generic functions that process author and journal data)=================== -------main program-------- # # The main program # set AuthorList to empty list set JournalList to empty list open input file FOR each Line of input file extract Authors from Line FOR each Author in Authors CALL AddToList with AuthorList and Author ENDFOR extract Journal from Line CALL addToList with JournalList and Journal ENDFOR close input file CALL PrintList with AuthorList CALL PrintList with JournalList ------PrintList( List )------ # # The PrintList function sorts the supplied List and prints it to the screen. # CALL SortList with List CALL GetNumberLinesOnScreen RETURNING NumLines CALCULATE number of screens needed to display List FOR each screen PRINT next NumLines - 1 items from List PROMPT user to press return to display next screen ENDFOR ------AddToList( List, Item )------ # # The AddToList function adds the supplied Item to the List. If the Item is already in the List # then it is left unchanged. # CALL GetItemNumber RETURNING ItemNum IF ItemNum = -1 THEN append Item to List ENDIF ------GetItemNumber( List, Item )------ # # The GetItemNumber function determines the index of supplied Item in List. # If Item is not in List then return -1. # Otherwise return the item's index, which will be in the range 0 to list length - 1. # set ItemNum to -1 set ItemCount to 0 WHILE ItemCount < number of items in List and ItemNum = -1 THEN IF Item = List[ItemCount] ItemNum = ItemCount ENDIF INCREMENT ItemCount ENDWHILE RETURN ItemNum