Readfemale else output malename maleloss to

This preview shows page 20 - 24 out of 41 pages.

readFemale()elseoutput maleName, maleLoss to mergedFilereadMale()endifcheckEnd()returnfinishUp()close femaleFileclose maleFileclose mergedFile20
Programming Logic and Design, 7eSolutions 7-return6.a. The Curl Up and Dye Beauty Salon maintains a master file that contains a record for each of its clients. Fields in the master file include the client’s ID number,first name, last name, and total amount spent this year. Every week, a transaction file is produced. It contains a customer’s ID number, the service received (for example, Manicure), and the price paid. Each file is sorted in ID number order. Design the logic for a program that matches the master and transaction file records and updates the total paid for each client by adding the current week’s price paid to the cumulative total. Not all clients purchase services each week. The output is the updated master file and an error report that lists any transaction records for which nomaster record exists.
21
Programming Logic and Design, 7eSolutions 7-Pseudocode:startDeclarationsInputFile masterFileInputFile transFileOutputFile updatedFilenum masterIdstring masterFirstNamestring masterLastNamenum masterTotalnum transIdnum transTotalstring transServicestring areBothAtEnd= “N”num END_ID = 999getReady()while areBothAtEnd <> “Y”updateRecords()endwhilefinishUp()stopgetReady()open masterFile “CurlUpAndDyeMaster.txt”open transFile “CurlUpAndDyeTransactions.txt”open updatedFile “UpdatedClients.txt”readMaster()readTrans()checkEnd()return22
Programming Logic and Design, 7eSolutions 7-readMaster()input masterId, masterFirstName, masterLastName, masterTotal from masterFileif eof thenmasterId = END_IDendifreturnreadTrans()input transId, transService, transTotal from transFileif eof thentransId = END_IDendifreturncheckEnd()if masterId = END_ID thenif transId = END_ID thenareBothAtEnd = “Y”endifendifreturnupdateRecords()if transId = masterId thenmasterTotal = masterTotal + transTotaloutput masterId, masterFirstName, masterLastName, masterTotal to updatedFilereadMaster()readTrans()elseif transId > masterId thenoutput masterId, masterFirstName, masterLastName, masterTotal to updatedFilereadMaster()elseoutput “No master record for transaction ”, transIdreadTrans()endifendifcheckEnd()returnfinishUp()close masterFileclose transFileclose updatedFilereturn

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture