Professional Documents
Culture Documents
Full download Programming Logic and Design Comprehensive 7th Edition Joyce Farrell Solutions Manual all chapter 2024 pdf
Full download Programming Logic and Design Comprehensive 7th Edition Joyce Farrell Solutions Manual all chapter 2024 pdf
https://testbankfan.com/product/programming-logic-and-design-
comprehensive-7th-edition-joyce-farrell-test-bank/
https://testbankfan.com/product/object-oriented-approach-to-
programming-logic-and-design-4th-edition-joyce-farrell-solutions-
manual/
https://testbankfan.com/product/object-oriented-approach-to-
programming-logic-and-design-4th-edition-joyce-farrell-test-bank/
https://testbankfan.com/product/java-programming-7th-edition-
joyce-farrell-solutions-manual/
Java Programming 7th Edition Joyce Farrell Test Bank
https://testbankfan.com/product/java-programming-7th-edition-
joyce-farrell-test-bank/
https://testbankfan.com/product/just-enough-programming-logic-
and-design-2nd-edition-farrell-test-bank/
https://testbankfan.com/product/java-programming-9th-edition-
joyce-farrell-solutions-manual/
https://testbankfan.com/product/java-programming-8th-edition-
joyce-farrell-solutions-manual/
https://testbankfan.com/product/java-programming-9th-edition-
joyce-farrell-test-bank/
Programming Logic and Design, 7e Solutions 7-1
Chapter 7
Exercises
1. 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 3. Design 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 eof is encountered and produce enough
mailing labels for each order.
Answer:
A sample solution follows
Flowchart:
Programming Logic and Design, 7e Solutions 7-2
Pseudocode:
start
Declarations
InputFile customerData
OutputFile mailingLabels
string title
string firstName
string lastName
string streetAddress
string city
string state
num zip
num numBoxes
Programming Logic and Design, 7e Solutions 7-3
num count
housekeeping()
while not eof
detailLoop()
endwhile
finishUp()
stop
housekeeping()
open customerData “VernonHillsMailOrderBoxes.txt”
open mailingLabels “CustomerMailingLabels.txt”
input title, firstName, lastName, streetAddress, city, state,
zip, numBoxes from customerData
return
detailLoop()
count = 0
while count < numBoxes
count = count + 1
output title, firstName, lastName to mailingLabels
output streetAddress to mailingLabels
output city, state, zip to mailingLabels
output “Box ”, count, “ of “, numBoxes to mailingLabels
endwhile
input title, firstName, lastName, streetAddress, city, state,
zip, numBoxes from customerData
return
finishUp()
close customerData
close mailingLabels
return
2. 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.
Answer:
A sample solution follows
Flowchart:
Programming Logic and Design, 7e Solutions 7-4
Pseudocode:
start
Declarations
InputFile femaleFile
Programming Logic and Design, 7e Solutions 7-5
InputFile maleFile
OutputFile mergedFile
num femaleId
string femaleLastName
string femaleFirstName
string femaleAddress
num maleId
string maleLastName
string maleFirstName
string maleAddress
string areAreBothAtEnd= “N”
num END_ID = 999
getReady()
while areAreBothAtEnd<> “Y”
mergeRecords()
endwhile
finishUp()
stop
getReady()
open femaleFile “CupidMatchmakingFemale.txt”
open maleFile “CupidMatchmakingMale.txt”
open mergedFile “CupidMatchmaking.txt”
readFemale()
readMale()
checkEnd()
return
readFemale()
input femaleId, femaleLastName, femaleFirstName, femaleAddress
from femaleFile
if eof then
femaleId = END_ID
endif
return
readMale()
input maleId, maleLastName, maleFirstName, maleAddress
from maleFile
if eof then
maleId = END_ID
endif
return
checkEnd
if femaleId = END_ID then
if maleId = END_ID then
areAreBothAtEnd= “Y”
endif
endif
return
mergeRecords()
if femaleId < maleId then
output femaleId, femaleLastName, femaleFirstName,
femaleAddress to mergedFile
readFemale()
Programming Logic and Design, 7e Solutions 7-6
else
output maleId, maleLastName, maleFirstName,
maleAddress to mergedFile
readMale()
endif
checkEnd()
return
finishUp()
close femaleFile
close maleFile
close mergedFile
return
3. Laramie Park District has files of participants in its summer and winter programs this
year. Each file is in participant ID number order and contains additional fields for
first name, last name, age, and class taken (for example, Beginning Swimming).
a. Design the logic for a program that merges the files for summer and winter
programs to create a list of the first and last names of all participants for the year.
Answer:
A sample solution follows
Flowchart:
Programming Logic and Design, 7e Solutions 7-7
Pseudocode:
start
Declarations
Programming Logic and Design, 7e Solutions 7-8
InputFile summerFile
InputFile winterFile
OutputFile mergedFile
num summerId
num summerAge
string summerFirst
string summerLast
string summerClass
num winterId
num winterAge
string winterFirst
string winterLast
string winterClass
string areBothAtEnd= “N”
num END_ID = 999999
getReady()
while areBothAtEnd <> “Y”
mergeRecords()
endwhile
stop
getReady()
open summerFile “LaramieParkDistrictSummer.txt”
open winterFile “LaramieParkDistrictWinter.txt”
open mergedFile “LaramieParkDistrict.txt”
readSummer()
readWinter()
checkEnd()
return
readSummer()
input summerId, summerFirst, summerLast, summerAge,
summerClass from summerFile
if eof then
summerId = END_ID
endif
return
readWinter()
input winterId, winterFirst, winterLast, winterAge,
winterClass from winterFile
if eof then
winterId = END_ID
endif
return
checkEnd()
if summerId = END_ID AND winterId = END_ID then
areBothAtEnd= “Y”
endif
return
mergeRecords()
if summerId < winterId then
output summerFirst, summerLast to mergedFile
readSummer()
else
Programming Logic and Design, 7e Solutions 7-9
finishUp()
close summerFile
close winterFile
close mergedFile
return
b. Modify the library program so that if a participant has more than one record, you
output the participant’s name only once.
Answer:
A sample solution follows
Flowchart:
Programming Logic and Design, 7e Solutions 7-10
Programming Logic and Design, 7e Solutions 7-11
Pseudocode:
start
Declarations
InputFile summerFile
InputFile winterFile
OutputFile mergedFile
num saveId = 0
num summerId
num summerAge
string summerFirst
string summerLast
string summerClass
num winterId
num winterAge
string winterFirst
string winterLast
string winterClass
string areBothAtEnd= “N”
num END_ID = 999999
getReady()
while areBothAtEnd <> “Y”
mergeRecords()
endwhile
stop
getReady()
open summerFile “LaramieParkDistrictSummer.txt”
open winterFile “LaramieParkDistrictWinter.txt”
open mergedFile “LaramieParkDistrict.txt”
readSummer()
readWinter()
checkEnd()
return
readSummer()
input summerId, summerFirst, summerLast, summerAge,
summerClass from summerFile
if eof then
summerId = END_ID
endif
return
readWinter()
input winterId, winterFirst, winterLast, winterAge,
winterClass from winterFile
if eof then
winterId = END_ID
endif
return
checkEnd()
if summerId = END_ID AND winterId = END_ID then
areBothAtEnd= “Y”
endif
return
Programming Logic and Design, 7e Solutions 7-12
mergeRecords()
if summerId < winterId then
if summerId <> savedId then
output summerFirst, summerLast to mergedFile
savedId = summerId
endif
readSummer()
else
if winterId <> savedId then
output winterFirst, winterLast to mergedFile
savedId = winterId
endif
readWinter()
endif
checkEnd()
return
finishUp()
close summerFile
close winterFile
close mergedFile
return
c. Modify the library program so that if a participant has more than one record, you
output the name only once, but you also output a count of the total number of classes
the participant has taken.
Answer:
A sample solution follows
Flowchart: (Only the modules that have changed from part b are shown below)
Programming Logic and Design, 7e Solutions 7-13
Programming Logic and Design, 7e Solutions 7-14
Pseudocode:
start
Declarations
InputFile summerFile
InputFile winterFile
OutputFile mergedFile
num saveId = 0
num count = 0
num summerId
num summerAge
string summerFirst
string summerLast
string summerClass
num winterId
num winterAge
string winterFirst
string winterLast
string winterClass
string areBothAtEnd= “N”
num END_ID = 999999
getReady()
while areBothAtEnd <> “Y”
mergeRecords()
endwhile
stop
getReady()
open summerFile “LaramieParkDistrictSummer.txt”
open winterFile “LaramieParkDistrictWinter.txt”
open mergedFile “LaramieParkDistrict.txt”
readSummer()
readWinter()
checkEnd()
return
readSummer()
input summerId, summerFirst, summerLast, summerAge,
summerClass from summerFile
if eof then
summerId = END_ID
endif
return
readWinter()
input winterId, winterFirst, winterLast, winterAge,
winterClass from winterFile
if eof then
winterId = END_ID
endif
return
checkEnd()
if summerId = END_ID AND winterId = END_ID then
areBothAtEnd= “Y”
endif
Programming Logic and Design, 7e Solutions 7-15
return
mergeRecords()
if summerId < winterId then
if summerId <> savedId then
if count > 1 then
controlBreak()
endif
output summerFirst, summerLast to mergedFile
savedId = summerId
endif
readSummer()
else
if winterId <> savedId then
if count > 1 then
controlBreak()
endif
output winterFirst, winterLast to mergedFile
savedId = winterId
endif
readWinter()
endif
count = count + 1
checkEnd()
return
controlBreak()
output “Count for ”, savedId, “ = ”, count to mergedFile
count = 0
return
finishUp()
if count > 1 then
controlBreak()
endif
close summerFile
close winterFile
close mergedFile
return
4. The Apgar Medical group keeps a patient file for each doctor in the office. Each
record contains the patient’s first and last name, home address, and birth year. The
records are sorted in ascending birth year order. Two doctors, Dr. Best and Dr.
Cushing, have formed a partnership. Design the logic that produces a merged list of
their patients in ascending order by birth year.
Answer:
A sample solution follows
Flowchart:
Programming Logic and Design, 7e Solutions 7-16
Pseudocode:
start
Declarations
InputFile bestFile
InputFile cushingFile
Programming Logic and Design, 7e Solutions 7-17
OutputFile mergedFile
num bestBirthYr
string bestFirst
string bestLast
string bestAddress
num cushingBirthYr
string cushingFirst
string cushingLast
string cushingAddress
string areBothAtEnd= “N”
num END_YEAR = 0
getReady()
while areBothAtEnd <> “Y”
mergeRecords()
endwhile
finishUp()
stop
getReady()
open bestFile “ApgarMedicalBest.txt”
open cushingFile “ApgarMedicalCushing.txt”
open mergedFile “ApgarMedical.txt”
readBest()
readCushing()
checkEnd()
return
readBest()
input bestFirst, bestLast, bestAddress, bestBirthYr from bestFile
if eof then
bestBirthYr = END_YEAR
endif
return
readCushing()
input cushingFirst, cushingLast, cushingAddress, cushingBirthYr
from cushingFile
if eof then
cushingBirthYr = END_YEAR
endif
return
checkEnd()
if bestBirthYr = END_YEAR then
if cushingBirthYr = END_YEAR then
areBothAtEnd = “Y”
endif
endif
return
mergeRecords()
if bestBirthYr > cushingBirthYr then
output bestFirst, bestLast, bestAddress, bestBirthYr
to mergedFile
readBest()
else
output cushingFirst, cushingLast, cushingAddress,
Programming Logic and Design, 7e Solutions 7-18
cushingBirthYr to mergedFile
readCushing()
endif
checkEnd()
return
finishUp()
close bestFile
close cushingFile
close mergedFile
return
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.
Answer:
A sample solution follows
Flowchart:
Programming Logic and Design, 7e Solutions 7-19
Pseudocode:
start
Declarations
InputFile femaleFile
InputFile maleFile
OutputFile mergedFile
string femaleName
num femaleLoss
Programming Logic and Design, 7e Solutions 7-20
string maleName
num maleLoss
string areBothAtEnd = “N”
num END_LOSS = 99999
getReady()
while areBothAtEnd <> “Y”
mergeRecords()
endwhile
finishUp()
stop
getReady()
open femaleFile “MartinWeightLossClinicFemale.txt”
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
Another random document with
no related content on Scribd:
XXII luku.
XXIII luku.
XXIV luku.
Bonnetin laivan nimi oli Revenge (Kosto), joka sopi sille yhtä
huonosti kuin sen päällikölle ammattinsa, sillä majurilla ei ollut
kostettavaa yhdellekään ihmiselle, jollei omavaltaiselle
aviopuolisolleen. Mutta "Kosto" oli niin monen muunkin kuuluisan
sissilaivan nimenä, että Bonnetin oli tietysti tässäkin suhteessa
seurattava jaloja esikuvia.
XXV luku.
Kaikki nämä varustelut veivät hyvän joukon aikaa, niin että kun
Bonnet viimein oli valmiina lähtemään merelle, sai hän kuulla uutisia,
jotka kiirehtivät häntä nopeasti muuttamaan mieltänsä ja
matkasuunnitelmaansa. Hän oli arvellut, että Mustaparta, jonka
kelvotonta ja ylimielistä käytöstä hän ei voinut muuten muistella kuin
vihan vimmalla, oli jäänyt maihin pitemmäksi aikaa
makeanleivänpäiviä viettämään; mutta nytpä kertoikin hänelle
muutaman pienen kauppalaivan kapteeni, että tuo vanha sankari
myöskin varusteli itseään uudelle retkelle ja että hän paraikaa
touhusi laivallaan Ocracoke-salmessa. Silloin pani Bonnet käsivarret
ristiin rinnalleen ja polki jalkaa komentosiltaan. Nyt oli tullut sopivin
hetki, jolloin hänen laivansa voi kunnialla ansaita nimensä. Hän
tahtoi kostaa Mustaparralle!