Visual Logic and Design 8th Edition Chapter 7 Debug Program

These solutions below just need to be built in Visual Logic.
Debug 01

// Each time a salesperson sells a car at the
// Pardeeville New and Used Auto Dealership,
// a record is created containing the salesperson’s
// name and the amount of the sale.
// Sales of new and used cars are kept in separate files
// because several reports are created for one type
// of sale or the other. However, management has requested
// a merged file so that all of a salesperson’s sales,
// whether the vehicle was new or used,
// are displayed together. The following code is intended
// to merge the files that have already been
// sorted by salesperson ID number.

start
   Declarations
      string newSalesperson
      num newAmount
      string usedSalesperson
      num usedAmount
      string bothAtEof = "N"
      string HIGH_NAME = "ZZZZZ"
      InputFile newSales
      InputFile usedSales
      OutputFile allsales
   getReady()
   while bothAtEof = "N"
      //  bothAtEof must be "N" for loop to continue  
      detailLoop()
   endwhile
   finish()
stop 
 
getReady()
   open newSales "NewSales.dat"
   open usedSales "UsedSales.dat"
   open allSales "AllSales.dat"
   input newSalesperson, newAmount from newSales
   if eof then
      newSalesperson = HIGH_NAME
         // newSalesperson should be set to HIGH_NAME
   endif
   input usedSalesperson, usedAmount from usedSales
   if eof then
      usedSalesperson = HIGH_NAME
         // usedSalesperson was misspelled
   endif

   if newSalesperson = HIGH_NAME AND usedSalesperson = HIGH_NAME then
      bothAtEof = "Y"
   endif
return

detailLoop()
   if newSalesperson > usedSalesperson then
      output usedSalesperson, usedAmount to allSales
      input usedSalesperson, usedAmount from usedSales
          // input should come from used file
      if eof then
         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

Debug 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

Debug 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
   readMaster()
   readTrans()
return

noMasterForTrans()
   output "No master file record matches transaction ", transID
      // should display transID
   readTrans()
return

noTransForMaster()
   output masterID, masterName, masterCredits to newMaster
   readMaster()
     // should call readMaster()
return

allDone()
   close master
   close trans
   close newMaster
return

Debug 04 must be corrected and put into Visual Logic and pseudo code.
debug07-04a

debug07-04b



This slideshow requires JavaScript.


This assignment includes pseudocodes and visual logic programs

  • Attachments
    • Visual_Logic_and_Design_8th_Edition_Chapter_7_Debug_Program.zip (286.43 KB)
      • DEBUG-01-02-03.docx
      • DEBUG04.doc
      • DEBUG07-01-Screenshot.png
      • DEBUG07-02-Screenshot.png
      • DEBUG07-03-Screenshot.png
      • DEBUG07-04-Screenshot.png
      • input
        • CustomersByZip.dat
        • NewSales.dat
        • roomAFile.dat
        • roomBFile.dat
        • semesterCredits.dat
        • studentFile.dat
        • UsedSales.dat
      • readme.txt
      • Visual Logic programs
        • DEBUG07-01.vls
        • DEBUG07-02.vls
        • DEBUG07-03.vls
        • DEBUG07-04.vls



Purchasing Instruction
List Price: $19

Buy Now

Add to Cart

Note: We offer a discount for buyers who purchase multiple items.