Two Find Bugs Examine Pseudocode Follows Introductory Comments Find Correct Bugs Correct C Q30121342

There are twoof them – I only have to find the bugs

Examine the pseudocodethat follows the introductory comments, then find and correct allthe bugs. Correct the code in this file, and be sure to clearlyhighlight the corrections.

1.     Debugging

Each time asalesperson sells a car at the Pardeeville New and Used AutoDealership, a record is created containing the salesperson’s nameand the amount of the sale. Sales of new and used cars are kept inseparate files because several reports are created for each saletype. However, management has requested a merged file so that allof the sales, whether the vehicle was new or used, are displayedtogether for each salesperson. The following code is intended tomerge the files that have already been sorted by salesperson IDnumber.

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 = “Y”

             detailLoop()

      endwhile

      finish()

stop

getReady()

      open newSales “NewSales.dat”

      open usedSales “UsedSales.dat”

      open allSales “AllSales.dat”

      input newSalesperson, newAmount fromnewSales

      if eof then

         usedSalesperson = HIGH_NAME

      endif

      input usedSalesperson, usedAmountfrom usedSales

      if eof then

         usedsalesPerson = HIGH_NAME

      endif

      if newSalesperson = HIGH_NAME ANDusedSalesperson = HIGH_NAME then

          bothAtEof =”Y”

      endif

return

detailLoop()

      if newSalesperson >usedSalesperson then

           output usedSalesperson, usedAmount to allSales

           input newSalesperson, newAmount from newSales

           if eof then

               usedSalesperson = HIGH_NAME

           endif

      else

           output newSalesperson, newAmount to allSales

           input usedSalesperson, usedAmount from usedSales

           if eof then

               newSalesperson = HIGH_NAME

           endif

      endif

      if newSalesperson = HIGH_NAME ANDusedSalesperson = HIGH_NAME then

          bothAtEof =”Y”

      endif

return

finish()

      close newSales

      close usedSales

      close allSales

return

2.   Debugging

Two senior classhomerooms at Littleville High School are having a fundraising drivefor the prom. Each time a student solicits a contribution, a recordis created with the student’s name and the value. Two files havebeen created for Homeroom A and Homeroom B. Each file is sorted incontribution value order from highest to lowest. This programmerges the two files.

start

      Declarations

             string roomAName

             num roomAValue

             string roomBName

             num roomBValue

             string bothFilesDone = “N”

             num HIGH_VALUE = 999999

             InputFile roomAFile

             InputFile roomBFile

             InputFile mergedFile

      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 fromroomAFile

      if eof then

           roomAValue = HIGH_VALUE

      endif

return

readB()

      input roomBName, roomBValue fromroomBFile

      if eof then

           roomBValue = HIGH_VALUE

      endif

return

checkBoth()

      if roomAValue = HIGH_VALUE ANDroomBValue = HIGH_VALUE then

           bothFilesDone = “Y”

      endif

return

detailLoop()

      if roomAValue > roomBValuethen

           output roomBName, roomBValue to mergedFile

           readA()

      else

           output roomAName, roomAValue to mergedFile

           readB()

      endif

return

allDone()

      close roomAFile

      close roomBFile

      close mergeFile

return

"We Offer Paper Writing Services on all Disciplines, Make an Order Now and we will be Glad to Help"
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.