While arebothatend y mergerecords endwhile finishup

This preview shows page 21 - 26 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
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 21
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, 8e Solutions 7- to mergedFile readBest() else output cushingFirst, cushingLast, cushingAddress, cushingBirthYr to mergedFile readCushing() endif checkEnd() return finishUp() close bestFile close cushingFile close mergedFile return b. Modify the program so that it does not display patients’ names, but only produces a count of the number of patients born each year. 22
Programming Logic and Design, 8e Solutions 7- Pseudocode: start Declarations InputFile bestFile InputFile cushingFile OutputFile mergedFile num count = 0 23
Programming Logic and Design, 8e Solutions 7- num savedYr = 0 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 controlBreak() output “Count for ”, savedYr, “ = ”, count to mergedFile count = 0 return mergeRecords() 24
Programming Logic and Design, 8e Solutions 7- if bestBirthYr < cushingBirthYr then if bestBirthYr <> savedYr then if count > 1 then controlBreak() endif savedYr = bestBirthYr endif readBest() else if cushingBirthYr <> savedYr then if count > 1 then controlBreak() endif savedYr = cushingBirthYr endif readCushing() endif count = count + 1 checkEnd() return finishUp() if count > 1 then controlBreak() endif close bestFile close cushingFile close mergedFile return

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture