Usedsalesperson highname endif else output

This preview shows page 32 - 36 out of 360 pages.

usedSalesperson = HIGH_NAME endif else output newSalesperson, newAmount to allSales input newSalesperson, newAmount from newSales // input should come from new file if eof then newSalesperson = HIGH_NAME endif endif if newSalesperson = HIGH_NAME AND usedSalesperson = HIGH_NAME then bothAtEof = "Y" endif return finish() close newSales close usedSales close allSales return DEBUG07-02 // The two senior class homerooms at Littleville High School // are having a fundraising drive for the prom. Each time a student // solicits a contribution, a record is created with the // student's name and the value. Two files have been created for // Homeroom A and Homeroom B. Each file is sorted in contribution // value order from highest to lowest. This program merges the two files. start Declarations string roomAName num roomAValue string roomBName num roomBValue string bothFilesDone = "N" num HIGH_VALUE = 999999 InputFile roomAFile InputFile roomBFile OutputFile mergedFile // mergedFile is an OutputFile getReady() while bothFilesDone = "N"
detailLoop() endwhile allDone() stop getReady() open roomAFile "roomAFile.dat" open roomBFile "roomBFile.dat" open mergedFile "mergedFile.dat" readA() readB() checkBoth() return readA() input roomAName, roomAValue from roomAFile if eof then roomAValue = HIGH_VALUE endif return readB() input roomBName, roomBValue from roomBFile if eof then roomBValue = HIGH_VALUE endif return checkBoth() if roomAValue = HIGH_VALUE AND roomBValue = HIGH_VALUE then bothFilesDone = "Y" endif return detailLoop() if roomAValue < roomBValue then // if roomBValue is more, it should be written first output roomBName, roomBValue to mergedFile readB() // should call readB() else output roomAName, roomAValue to mergedFile readA() // should call readA() endif checkBoth() // should call checkBoth() return allDone()
close roomAFile close roomBFile close mergedFile // mergedFile is misspelled return DEBUG07-03 // Cooper College maintains a master file of students and credits // earned. Each semester the master is updated with a transaction // file that contains credits earned during the semester. // Each file is sorted in Student ID number order. start Declarations num masterID string masterName num masterCredits num transID num transCredits string bothDone = "N" num HIGH_VALUE = 999999 InputFile master InputFile trans OutputFile newMaster getReady() while bothDone = "N" detailLoop() endwhile allDone() stop getReady() open master "studentFile.dat" open trans "semesterCredits.dat" open newMaster "updatedStudentFile.dat" readMaster() readTrans() checkBoth() return readMaster() input masterID, masterName, masterCredits from master if eof then masterID = HIGH_VALUE endif return readTrans()
input transID, transCredits from trans if eof then transID = HIGH_VALUE endif return checkBoth() if masterID = HIGH_VALUE AND transID = HIGH_VALUE then bothDone = "Y" endif return detailLoop() if masterID = transID then match() else if masterID > transID then noMasterForTrans() else noTransForMaster() endif endif checkBoth() // must call checkBoth() return match() masterCredits = masterCredits + transCredits // should add transCredits to masterCredits output masterID, masterName, masterCredits to newMaster

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture