Week 4.docx - Laramie Park District has files of participants in its summer and winter programs this year Each file is in participant ID number order

Week 4.docx - Laramie Park District has files of...

This preview shows page 1 - 5 out of 16 pages.

Laramie Park District has files of participants in its summer and winter programs this year. Each file is in participant ID number order and contains additional fields for first name, last name, age, and class taken (for example, Beginning Swimming). a. Design the logic for a program that merges the files for summer and winter programs to create a list of the first and last names of all participants for the year. Laramie park district has files of participants in its summer and winter programs this year. Pseudocode: start Declarations InputFile summerFile InputFile winterFile OutputFile mergedFile 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 return mergeRecords() if summerId < winterId then output summerFirst, summerLast to mergedFile readSummer() else output winterFirst, winterLast to mergedFile readWinter() endif checkEnd() return finishUp() close summerFile close winterFile close mergedFile return

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture