B modify the program to output a coupon for a free

This preview shows page 23 - 29 out of 41 pages.

b. Modify the program to output a coupon for a free haircut each time a client exceeds $750 in services. The coupon, which contains the client’s name and an appropriate congratulatory message, is output during the execution of the update program when a client total surpasses $750. 23
Programming Logic and Design, 7e Solutions 7- Answer: A sample solution follows Flowchart: (Only the modules that have changed from part a are shown below) Pseudocode: start Declarations InputFile masterFile InputFile transFile OutputFile updatedFile num masterId string masterFirstName string masterLastName num masterTotal num transId num transMiles 24
Programming Logic and Design, 7e Solutions 7- num 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 if masterTotal > 750 AND (masterTotal–transTotal)< 750 then output “Congratulations! ”, masterFirstName, masterLastName, “ you have received a free haircut!” endif output masterId, masterFirstName, masterLastName, masterTotal to updatedFile readMaster() readTrans() else if transId > masterId then output masterId, masterFirstName, masterLastName, 25
Programming Logic and Design, 7e Solutions 7- 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 7. a. The Timely Talent Temporary Help Agency maintains an employee master file that contains an employee ID number, last name, first name, address, and hourly rate for each temporary worker. The file has been sorted in employee ID number order. Each week, a transaction file is created with a job number, address, customer name, employee ID, and hours worked for every job filled by Timely Talent workers. The transaction file is also sorted in employee ID order. Design the logic for a program that matches the master and transaction file records, and output one line for each transaction, indicating job number, employee ID number, hours worked, hourly rate, and gross pay. Assume that each temporary worker works at most one job per week; output one line for each worker who has worked that week. 26
Programming Logic and Design, 7e Solutions 7- Pseudocode: start Declarations InputFile masterFile InputFile transFile 27
Programming Logic and Design, 7e Solutions 7- OutputFile updatedFile num masterId string masterFirstName string masterLastName string masterAddress

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture