The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I need this debugged, please.
Â
// 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 = "Y"Â
     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Â
     usedSalesperson = HIGH_NAMEÂ
   endif
  input usedSalesperson, usedAmount from usedSalesÂ
  if eof thenÂ
     usedsalesPerson = HIGH_NAME
   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 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 AND usedSalesperson = HIGH_NAME thenÂ
       bothAtEof = "Y"Â
     endifÂ
return
finish()Â
  close newSalesÂ
  close usedSalesÂ
  close allSalesÂ
return
-----------