Question

The provided text files represents a working program that requires some maintenance or improvement. // Marian...

The provided text files represents a working program that requires some maintenance or improvement.

// Marian Basting takes in small sewing jobs.
// She has two files sorted by date.
// (The date is composed of two numbers -- month and year.)
// One file holds new sewing projects
// (such as "wedding dress")
// and the other contains repair jobs
// (such as "replace jacket zipper").
// Each file contains the month, day, client name, phone number,
// job description, and price.
// Currently, this program merges the files to produce
// a report that lists all of Marian's jobs for the year
// in date order.
// Modify the program to also display her total earnings
// at the end of each month as well as at the end of the year.
start
   Declarations
      num newMonth
      num newDay
      string newName
      string newPhone
      string newDescription
      num newPrice
      num repairMonth
      num repairDay
      string repairName
      string repairPhone
      string repairDescription
      num repairPrice
      num newDate
      num repairDate
      string bothAtEof = "N"
      num HIGH_MONTH = 99
      InputFile newJobs
      InputFile repairJobs
   getReady()
   while bothAtEof = "N"
      detailLoop()
   endwhile
   finish()
stop

getReady()
   open newJobs "NewJobs.dat"
   open repairJobs "RepairJobs.dat"
   input newMonth, newDay, newName, newPhone,
      newDescription, newPrice from newJobs
   if eof then
      newMonth = HIGH_MONTH
   endif
   input repairMonth, repairDay, repairName, repairPhone,
      repairDescription, repairPrice from repairJobs
   if eof then
      repairMonth = HIGH_MONTH
   endif

   if newMonth = HIGH_MONTH AND repairMonth = HIGH_MONTH then
      bothAtEof = "Y"
   endif
return

detailLoop()
   newDate = newMonth * 100 + newDay
   repairDate = repairMonth * 100 + repairMonth
      // This arithmetic turns each date into a 3- or 4-digit number
   if newDate > repairDate then
      output repairMonth, repairDay, repairName, repairPhone,          repairDescription, repairPrice
      input repairMonth, repairDay, repairName, repairPhone,
         repairDescription, repairPrice from repairJobs
      if eof then
         repairMonth = HIGH_MONTH
      endif
   else
      output newMonth, newDay, newName, newPhone,
          newDescription, newPrice
      input newMonth, newDay, newName, newPhone,
         newDescription, newPrice from newJobs
      if eof then
         newMonth = HIGH_MONTH
      endif
   endif
   if newMonth = HIGH_MONTH AND repairMonth = HIGH_MONTH then
      bothAtEof = "Y"
   endif
return

finish()
   close newJobs
   close repairJobs
return

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.....................................................................................................................

start
   Declarations
      num weddingMonth
      num weddingDay
      string weddingClientName
      num weddingPhoneNum
      string weddingDescription
      num weddingPrice
     num replaceMonth
      num replaceDay
      string replaceClientName
      num replacePhoneNum
      string replaceDescription
      num replacePrice
      num weddingDate
      num replaceDate
      num bothAtEnd=0
     num END_YEAR=9999
      InputFile weddingFile
      InputFile replaceFile
     ouputFile mergedFile


getReady()
while bothAtEnd<>1
mergeRecords()
   endwhile
   finishUp()
stop


getReady()
   open weddingFile "weddingDress.dat"
   open replaceFile "replaceJacketZipper.dat"
   open mergedFile “Merged.dat”
    readWedding()
   readreplace()
   checkEnd()
return

readWedding( )
      input weddingMonth,weddingDay,weddingClientName,weddingPhoneNum,weddingDescription,weddingPricee from weddingFile
while eof
  weddingDate=END_YEAR
endwhile
return


readreplace( )
      input replaceMonth,replaceDay,replaceClientName,replacePhoneNum,replaceDescription,replacePricee from replaceFile
while eof
  replaceDate=END_YEAR
endwhile
return

checkEnd()
if weddingDate=END_YEAR
if replaceDate=END_YEAR
bothAtEnd=1
endif
endif
return

mergedFile()
if weddingDate<replaceDate
          output weddingMonth,weddingDay,weddingClientName,weddingPhoneNum,weddingDescription,weddingPricee to weddingFile
readWedding()
endif
       output replaceMonth,replaceDay,replaceClientName,replacePhoneNum,replaceDescription,replacePricee to replaceFile
readreplace()
return
finishUp()
close weddingFile
close replaceFile
close mergedFile
return

........................................................................................................

Add a comment
Know the answer?
Add Answer to:
The provided text files represents a working program that requires some maintenance or improvement. // Marian...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT