Posted by Alisa on Sunday, April 29, 2012 at 1:09am.
Finding the bugs.
// Each time a salesperson sells a car at the Pardeeville New and Used Auto Dealership,
// a record is created containing the salespersons 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 salespersons 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 = 9999
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
newSalesperson = HIGH_NAME
endif
input usedSalesperson, usedAmount from usedSales
if eof then
usedSalesperson = newSalesperson
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
if eof then
usedSalesperson = HIGHNAME
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
If you can explain this to me that I can understand how to do it?
Answer this Question
Related Questions
Marketing - What marketing segmentation criteria could be used to find a person ...
MircroEconomics - Production & Cost - Please check my answers if they are ...
Word Problem Maximizing A Bonus - Pauline Wong spends 4 hours selling a used car...
Programming Logic - Programmign Logic for business Modify the PROCESS routine ...
You are interested in buying a new car and Bob let - You are interested in ...
financial resources - Bob Brown was recently involved in a minor auto accident. ...
Physics - A car accelerates steadly from zero to 30m/s in a distance d & a ...
MAth - what do you call a person who buys and sells bugs?
Early Childhood Education - Investigating the bugs the two children found on the...
financial resources - Assignment Type: Discussion Board Deliverable Length: 2-3...
For Further Reading