Ch 11 Exercise Answers

Submitted by: Submitted by

Views: 275

Words: 1998

Pages: 8

Category: Other Topics

Date Submitted: 01/16/2014 10:18 PM

Report This Essay

1. The Springwater Township School District has two high schools—Jefferson and Audubon. Each school maintains a student file with fields containing student ID, last name, first name, and address. Each file is in student ID number order. Write the flowchart or pseudocode for the program that merges the two files into one file containing a list of all students in the district, maintaining student ID number order.

Pseudocode:

start

perform housekeeping( )

while bothDone = "N"

perform mainLoop( )

endwhile

perform finishUp( )

stop

housekeeping( )

declare variables

open files

perform readJefferson( )

perform readAudubon( )

if jeffId = 9999 then

if audId = 9999 then

bothDone = "Y"

endif

endif

return

readJefferson( )

read jeffRec

if eof then

jeffId = 9999

endif

return

readAudubon( )

read audRec

if eof then

audId = 9999

endif

return

mainLoop( )

if jeffId > audId then

write audId, audLast, audFirst, audAddress

perform readAudubon( )

else

write jeffId, jeffLast, jeffFirst, jeffAddress

perform readJefferson( )

endif

if jeffId = 9999 then

if audId = 9999 then

bothDone = "Y"

endif

endif

return

finishUp( )

close files

return

Flow chart:

2. The Redgranite Library keeps a file of all books borrowed every month. Each file is in Library of Congress number order and contains additional fields for author and title.

a. Write the flowchart or pseudocode for the program that merges the files for January and February to create a list of all books borrowed in the two-month period.

Pseudocode:

start

perform housekeeping( )

while bothDone = "N"

perform mainLoop( )

perform finishUp( )

stop

housekeeping( )

declare variables

open files

perform readJan( )

perform readFeb( )

if janId = 9999 then

if febId = 9999 then

bothDone = "Y"

endif

endif

return

readJan( )

read janRec

if eof then

janId = 9999

endif

return...