Link to home
Start Free TrialLog in
Avatar of VinnyG3
VinnyG3Flag for United States of America

asked on

pseudocode question

I have some code that has some bugs in it. A standard mortgage is paid monthly over 30 years. This program is intended to print 360 payment coupons for a new borrower. Each coupon lists the month number, year number, and a friendly mailing reminder. Can you please help me fix this pseudocode.
start
     num MONTHS = 12
     num YEARS = 30
     string MSG = "remember to allow 5 days for mailing"
     num monthCounter = 1
     num yearCounter = 1 
     while yearCounter <= YEARS
           while monthCounter <= MONTHS
                 Print monthCounter, yearCounter, MSG
                 monthCounter = monthCounter + 1
            endwhile
     end while
stop

Open in new window

Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

The only thing that I notice is that yearCounter is not incremented at all.
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You do it alternatively with for loops which ought to be easier to see:

Chris
Start
     num MONTHS = 12
     num YEARS = 30
     string MSG = "remember to allow 5 days for mailing"
     num monthCounter = 1
     num yearCounter = 1
     For yearCounter = 1 To YEARS
           For monthCounter = 1 To MONTHS
                 Debug.Print monthCounter, yearCounter, MSG
           Next
     Next
Stop:

Open in new window

Avatar of VinnyG3

ASKER

Thanks guys