The Apgar Medical group keeps a patient file for each doctor in the office. Each
ID: 3545507 • Letter: T
Question
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 stored 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. Pseudocode only. Any help would be great! example of other solutions for other questions would be:
Start
Declarations
Num bookTotal = 0
Num bookPrice[1000]
String bookTitle[1000]
String bookAuthor[1000]
endDeclarations
initialGreeting() // Call the module
inputBooks() //Call the module
outputItems() //Call the module
sayGoodbye() //End the program
// Note how I did not execute any code above. The entire program was modularized.
Stop
initialGreeting()
output "Welcome. Please enter your book sale data."
return
inputItems() //Input info for books
for num loopVar = 0 to 999 Step 1 // Declare loopVar here
input "Enter the title: ", bookName[loopVar]
input "Enter the author: ", bookAuthor[loopVar]
input "Enter the price: ", bookPrice[loopVar]
bookTotal = bookTotal + bookPrice[loopVar]
endfor
return
outputItems() //Output the results
Output "Title Author Price"
for num loopVar = 0 to 999 Step 1
output bookName[loopVar] + " " + bookAuthor[loopVar] + " " + bookPrice[loopVar]
endfor
return
Explanation / Answer
Pseudocode:
Read first record from each file.
Do while data exists in either file.
--- Do while file1.birthyear < file2.birthyear
--- --- copy file1.record to file3
--- --- read next record from file1
--- End Do
--- Do while file2.birthyear < file1.birthyear
--- --- copy file2.record to file3
--- --- read next record from file2
--- End Do
End Do
-------
Edit: >>> "Not sure how to do that mate."
See, that's the thing about pseudocode, it says *what* to do, not *how* to do it.
Pseudocode has NO RULES.
However, a teacher might impose rules on the class and expect the class to follow examples of the pseudocode in the examples.
But we don't have your examples.
Because there are no rules, I can say:
Read first record from each file.
But you could change that to
Read first record from File1.
Read first record from File2.
And in a real program, the file would have to be opened first. It can be implied in pseudocode but if you think you need to be explicit then you could have
Open DrBestFile.dat as File1
Open DrCushingFile.dat as File2
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.