Logic7e_Solutions_ch07 - Programming Logic and Design 7e...

This preview shows page 1 - 6 out of 41 pages.

Programming Logic and Design, 7eSolutions 7-Programming Logic and Design, 7th EditionChapter 7Exercises1.The Vernon Hills Mail-Order Company often sends multiple packages per order. For each customer order, output enough mailing labels to use on each of the boxes that will be mailed. The mailing labels contain the customer’s complete name and address, along with a box number in the form Box 9 of 9. For example, an order that requires three boxes produces three labels: Box 1 of 3, Box 2 of 3, and Box 3 of 3Design an application that reads records that contain a customer’s title (for example, Mrs.), first name, last name, street address, city, state, zip code, and number of boxes. The application must read the records until eofis encountered and produce enough mailing labels for each order..
1
Programming Logic and Design, 7eSolutions 7-Pseudocode:startDeclarationsInputFile customerDataOutputFile mailingLabelsstring titlestring firstNamestring lastNamestring streetAddressstring citystring statenum zipnum numBoxes2
Programming Logic and Design, 7eSolutions 7-num counthousekeeping()while not eofdetailLoop()endwhilefinishUp()stophousekeeping()open customerData “VernonHillsMailOrderBoxes.txt”open mailingLabels “CustomerMailingLabels.txt”input title, firstName, lastName, streetAddress, city, state, zip, numBoxes from customerDatareturndetailLoop()count = 0while count < numBoxescount = count + 1output title, firstName, lastName to mailingLabelsoutput streetAddress to mailingLabelsoutput city, state, zip to mailingLabelsoutput “Box ”, count, “ of “, numBoxes to mailingLabelsendwhileinput title, firstName, lastName, streetAddress, city, state, zip, numBoxes from customerDatareturnfinishUp()close customerDataclose mailingLabelsreturn2.The Cupid Matchmaking Service maintains two files—one for male clients and another for female clients. Each file contains a client ID, last name, first name, and address. Each file is in client ID number order. Design the logic for a program that merges the two files into one file containing a list of all clients, maintaining ID number order.
3
Programming Logic and Design, 7eSolutions 7-Pseudocode:startDeclarationsInputFile femaleFile4
Programming Logic and Design, 7eSolutions 7-InputFile maleFileOutputFile mergedFilenum femaleIdstring femaleLastNamestring femaleFirstNamestring femaleAddressnum maleIdstring maleLastNamestring maleFirstNamestring maleAddressstring areAreBothAtEnd= “N”num END_ID = 999getReady()while areAreBothAtEnd<> “Y”mergeRecords()endwhilefinishUp()stopgetReady()open femaleFile “CupidMatchmakingFemale.txt”open maleFile “CupidMatchmakingMale.txt”open mergedFile “CupidMatchmaking.txt”readFemale()readMale()checkEnd()returnreadFemale()input femaleId, femaleLastName, femaleFirstName, femaleAddress from femaleFileif eof thenfemaleId = END_IDendifreturnreadMale()input maleId, maleLastName, maleFirstName, maleAddress from maleFileif eof thenmaleId = END_IDendif

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture