Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// A standard mortgage is paid monthly over 30 years. // This program is intende

ID: 3921359 • Letter: #

Question

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


Can you please help me debug this code, Thanks!

Explanation / Answer

This looks ok but there seems to be a glitch in the printCoupons function. The variable monthCounter hasnt been declared and initialised . So that is where the error is. The variable yearCounter is declared but not initialised. Check that out once.