The martin weight loss clinic maintains two patient

This preview shows page 25 - 31 out of 62 pages.

We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Linux+ and LPIC-1 Guide to Linux Certification
The document you are viewing contains questions related to this textbook.
Chapter 4 / Exercise 10
Linux+ and LPIC-1 Guide to Linux Certification
Eckert
Expert Verified
5.The Martin Weight Loss Clinic maintains two patient files—one for male clients and one for female clients. Each record contains the name of a patient and current total weight loss in pounds. Each file is in descending weight loss order. Design the logic that merges the two files to produce one combined file in order by weight loss.
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Linux+ and LPIC-1 Guide to Linux Certification
The document you are viewing contains questions related to this textbook.
Chapter 4 / Exercise 10
Linux+ and LPIC-1 Guide to Linux Certification
Eckert
Expert Verified
Programming Logic and Design, 8eSolutions 7-Pseudocode:startDeclarationsInputFile femaleFileInputFile maleFileOutputFile mergedFilestring femaleNamenum femaleLoss26
Programming Logic and Design, 8eSolutions 7-string maleNamenum maleLossstring areBothAtEnd = “N”num END_LOSS = 99999getReady()while areBothAtEnd <> “Y”mergeRecords()endwhilefinishUp()stopgetReady()open femaleFile “MartinWeightLossClinicFemale.txt”open maleFile “MartinWeightLossClinicMale.txt”open mergedFile “MartinWeightLossClinic.txt”readFemale()readMale()checkEnd()returnreadFemale()input femaleName, femaleLoss from femaleFile if eof thenfemaleLoss = END_LOSSendifreturnreadMale()input maleName, maleLoss from maleFile if eof thenmaleLoss = END_LOSSendifreturncheckEnd()if femaleLoss = END_LOSS thenif maleLoss = END_LOSS thenareBothAtEnd = “Y”endifendifreturnmergeRecords()if femaleLoss > maleLoss thenoutput femaleName, femaleLoss to mergedFilereadFemale()elseoutput maleName, maleLoss to mergedFilereadMale()endifcheckEnd()returnfinishUp()close femaleFileclose maleFileclose mergedFile27
Programming Logic and Design, 8eSolutions 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.
28
Programming Logic and Design, 8eSolutions 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()return29
Programming Logic and Design, 8eSolutions 7-readMaster()input masterId, masterFirstName, masterLastName, masterTotal from masterFileif eof thenmasterId = END_IDendifreturnreadTrans()

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture