Close mergedfile return answer flowchart pseudocode

This preview shows page 15 - 19 out of 360 pages.

close mergedFile return 5. The Martin Weight Loss Clinic maintains two patient files—one for male clients and one for A sample solution follows
open maleFile “MartinWeightLossClinicMale.txt” open mergedFile “MartinWeightLossClinic.txt” readFemale() readMale() checkEnd() return readFemale() input femaleName, femaleLoss from femaleFile if eof then femaleLoss = END_LOSS endif return readMale() input maleName, maleLoss from maleFile if eof then maleLoss = END_LOSS endif return checkEnd() if femaleLoss = END_LOSS then if maleLoss = END_LOSS then areBothAtEnd = “Y” endif endif return mergeRecords() if femaleLoss > maleLoss then output femaleName, femaleLoss to mergedFile readFemale() else output maleName, maleLoss to mergedFile readMale() endif checkEnd() return finishUp() close femaleFile close maleFile close mergedFile return 6. a. The Curl Up and Dye Beauty Salon maintains a master file that contains a record for each
A sample solution follows
Flowchart: Pseudocode: start Declarations InputFile masterFile InputFile transFile OutputFile updatedFile num masterId string masterFirstName string masterLastName num masterTotal num transId num transTotal string transService string areBothAtEnd= “N” num END_ID = 999 getReady() while areBothAtEnd <> “Y” updateRecords() endwhile finishUp() stop getReady() open masterFile “CurlUpAndDyeMaster.txt” open transFile “CurlUpAndDyeTransactions.txt” open updatedFile “UpdatedClients.txt” readMaster() readTrans() checkEnd() return readMaster() input masterId, masterFirstName, masterLastName, masterTotal from masterFile if eof then masterId = END_ID endif return readTrans() input transId, transService, transTotal from transFile if eof then transId = END_ID endif return
checkEnd() if masterId = END_ID then if transId = END_ID then areBothAtEnd = “Y” endif endif return updateRecords() if transId = masterId then masterTotal = masterTotal + transTotal output masterId, masterFirstName, masterLastName, masterTotal to updatedFile readMaster() readTrans() else if transId > masterId then output masterId, masterFirstName, masterLastName, masterTotal to updatedFile readMaster() else output “No master record for transaction ”, transId readTrans() endif endif checkEnd() return finishUp() close masterFile close transFile close updatedFile return

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture