Input winterid winterfirst winterlast winterage

This preview shows page 11 - 16 out of 41 pages.

input winterId, winterFirst, winterLast, winterAge, winterClass from winterFile if eof then winterId = END_ID endif return checkEnd() if summerId = END_ID AND winterId = END_ID then areBothAtEnd= “Y” endif return 11
Programming Logic and Design, 7e Solutions 7- mergeRecords() if summerId < winterId then if summerId <> savedId then output summerFirst, summerLast to mergedFile savedId = summerId endif readSummer() else if winterId <> savedId then output winterFirst, winterLast to mergedFile savedId = winterId endif readWinter() endif checkEnd() return finishUp() close summerFile close winterFile close mergedFile return c. Modify the library program so that if a participant has more than one record, you output the name only once, but you also output a count of the total number of classes the participant has taken. 12
Programming Logic and Design, 7e Solutions 7- 13
Programming Logic and Design, 7e Solutions 7- Pseudocode: start Declarations InputFile summerFile InputFile winterFile OutputFile mergedFile num saveId = 0 num count = 0 num summerId num summerAge string summerFirst string summerLast string summerClass num winterId num winterAge string winterFirst string winterLast string winterClass string areBothAtEnd= “N” num END_ID = 999999 getReady() while areBothAtEnd <> “Y” mergeRecords() endwhile stop getReady() open summerFile “LaramieParkDistrictSummer.txt” open winterFile “LaramieParkDistrictWinter.txt” open mergedFile “LaramieParkDistrict.txt” readSummer() readWinter() checkEnd() return readSummer() input summerId, summerFirst, summerLast, summerAge, summerClass from summerFile if eof then summerId = END_ID endif return readWinter() input winterId, winterFirst, winterLast, winterAge, winterClass from winterFile if eof then winterId = END_ID endif return checkEnd() if summerId = END_ID AND winterId = END_ID then areBothAtEnd= “Y” endif 14
Programming Logic and Design, 7e Solutions 7- return mergeRecords() if summerId < winterId then if summerId <> savedId then if count > 1 then controlBreak() endif output summerFirst, summerLast to mergedFile savedId = summerId endif readSummer() else if winterId <> savedId then if count > 1 then controlBreak() endif output winterFirst, winterLast to mergedFile savedId = winterId endif readWinter() endif count = count + 1 checkEnd() return controlBreak() output “Count for ”, savedId, “ = ”, count to mergedFile count = 0 return finishUp() if count > 1 then controlBreak() endif close summerFile close winterFile close mergedFile return

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture