. Assume that this program is a working program in your organization and that it
ID: 3759264 • Letter: #
Question
. Assume that this program is a working program in your organization and that it needs modifications as described in the comments (lines that begin with two slashes) at the beginning of the file. Your job is to alter the program to meet the new specifications.
// 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
num Tearnings
num TearningsMonth
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
Explanation / Answer
Provided Pseudocode as per your new specifications:
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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.