Modify these programs. Instructions are //at top of the programs. Chapter 5 Prog
ID: 3764944 • Letter: M
Question
Modify these programs. Instructions are //at top of the programs.
Chapter 5 Programming Logic and Design 8th Edition Joyce Farrell
// This program is supposed to display every fifth year
// starting with 2015; that is, 2015, 2020, 2025,
// and so on, for 30 years.
start
Declarations
num year
num START_YEAR = 2015
num FACTOR = 5
num END_YEAR = 30
year = START_YEAR
while year <= END_YEAR
output year
endwhile
stop
Second program to modify
// A standard mortgage is paid monthly over 30 years.
// This program is intended to output 360 payment coupons
// for each new borrower at a mortgage company.
// Each coupon lists the month number, year number,
// and a friendly mailing reminder.
start
Declarations
num MONTHS = 12
num YEARS = 30
string MSG = "Remember to allow 5 days for mailing"
num acctNum
num yearCounter
housekeeping()
while acctNUm <> QUIT
printCoupons()
endwhile
finish()
stop
housekeeping()
print "Enter account number or ", QUIT, " to quit "
input acctNum
return
printCoupons()
while yearCounter <= YEARS
while monthCounter <= MONTHS
print acctNum, monthCounter, yearCounter, MSG
monthCounter = monthCounter + 1
endwhile
endwhile
output "Enter account number or ", QUIT, " to quit "
input acctNum
return
finish()
output "End of job"
return
Explanation / Answer
Following are the modified programs
1
start
Declarations
num year
num START_YEAR = 2015
num FACTOR = 5
num END_YEAR = 30
num COUNTER = 0
year = START_YEAR
while COUNTER <= END_YEAR
print year;
year = year + FACTOR;
COUNTER = COUNTER + FACTOR;
endwhile
stop
2
start
Declarations
num MONTHS = 12
num YEARS = 30
string MSG = "Remember to allow 5 days for mailing"
num acctNum
num yearCounter
housekeeping()
while acctNUm <> QUIT
printCoupons()
endwhile
finish()
stop
housekeeping()
print "Enter account number or ", QUIT, " to quit "
input acctNum
return
printCoupons()
while yearCounter <= YEARS
while monthCounter <= MONTHS
print acctNum, monthCounter, yearCounter, MSG
monthCounter = monthCounter + 1
endwhile
yearCounter = yearCounter + 1
endwhile
output "Enter account number or ", QUIT, " to quit "
input acctNum
return
finish()
output "End of job"
return
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.