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

VinnyG3Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
The only thing that I notice is that yearCounter is not incremented at all.
0
Chris BottomleySoftware Quality Lead EngineerCommented:
Hello VinnyG3,

Year counter needs to be incremented and month counter reset i.e. as below

Regards,
Chris
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
            yearCounter = yearCounter + 1
            monthCounter = 1
    end while
stop

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GrahamSkanRetiredCommented:
Also monthCounter is not being restarted, so it needs to be set to 1 for each year

Start
     num MONTHS = 12
     num YEARS = 30
     string MSG = "remember to allow 5 days for mailing"
     
     num yearCounter = 1
     While yearCounter <= YEARS
            num monthCounter = 1
             While monthCounter <= MONTHS
                 Print monthCounter, yearCounter, MSG
                 monthCounter = monthCounter + 1
            end while
            yearCounter = yearCounter + 1
     end while
Stop
0
Chris BottomleySoftware Quality Lead EngineerCommented:
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

0
VinnyG3Author Commented:
Thanks guys
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.