Programming logic

posted by .

Finding the bugs.

// 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 = 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?

  • Programming logic -

    Under the detailLoop() Statements

    In Else Part you have used wrong logic
    it should be like below

    else
    output newSalesperson, newAmount to allSales
    input newSalesperson, newAmount from newSales

  • Programming logic -

    Thank you syed!!

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Computer Flowcharts

    A department store pays its salesperson only by commission. A salesperson receives a commission of 25% on all sales if he/she has sold at least $50,000 worth of merchandise in a pay period. But only 15% if his/her sales are below $50,000. …
  2. Math

    The chart shows the number of cars sold per week at a car dealership during the month of June. Salesperson Week 1 Week 2 Week 3 Week 4 Tim 4 8 2 1 Geena 1 2 7 1 Rafael 2 1 5 4 Sonny 4 1 1 10 How should the data be displayed to make …
  3. Algebra

    Ms. Jones has two job offers as a car salesperson. At one dealership, she will receive $600 per month plus a commission of 2% of the total price of the automobiles she sells. At the other dealership, she will receive $1000 per month …
  4. lacco

    // 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 …
  5. programming

    a sales report. Each record in the file contains a customer's number and name, a sales amount and a tax code. The tax code is to be applied to the sales amount to determine the sales tax due for that sale, as follows: Tax code Sales …
  6. C++ program

    A company wants to know the percentages of total sales and total expenses attributable to each salesperson. The data is stored in a text file. In the file, each person has a pair of data lines. The first line contains …
  7. Math

    A salesperson's weekly paycheck is 25% less than a second salesperson's paycheck. The two paychecks total $1425. Find the amount of each paycheck. first salesperson's paycheck ?
  8. STATISTICS

    A salesperson contacts eight potential customers per day. From past experience, we know that the probability of a potential customer making a purchase is .05. b.) What is the probability the salesperson will make exactly two sales …
  9. Programming c++

    a sales report. Each record in the file contains a customer's number and name, a sales amount and a tax code. The tax code is to be applied to the sales amount to determine the sales tax due for that sale, as follows: Tax code Sales …
  10. Math

    A salesperson at a furniture store earns a 3% commission on all sales. How much commission does the salesperson earn on a $1400 sale?

More Similar Questions