loan.c bug

Charlie Crassi crassi at kodak.kodak.com
Wed Jan 16 02:55:25 AEST 1991


RE:bug in loan.c

In looking over the code, I believe I have discovered the problem
with the perceived bug.

If on the command line you enter the month as a alpha string, March,
the program prints a schedule from january of the specified year. 
However, in looking at the code, it expects the month to be a number
between 1 and 12. If you enter 3 instead of March, the program runs
and prints the schedule correctly. The followinf 2 lines of text 
illustrate the command line arguments in both the correct and incorrect
formats and the results.

RIGHT WAY:
loan 19200 6 30 5 1967
==========================================================================
 Loan amount: $19200.00     APR: 6.000%     Term: 30 years starting May 67

                      360 monthly payments of $115.11 

 Pay't   Date     Principal  Interest       Balance     Interest   Interest
  no.     due      Payment    Payment       of loan      (total)     (YTD)

    1   May 67       19.11      96.00      19180.89        96.00      96.00
    2   Jun 67       19.21      95.90      19161.68       191.90     191.90
    3   Jul 67       19.30      95.81      19142.38       287.71     287.71
    4   Aug 67       19.40      95.71      19122.98       383.42     383.42
    5   Sep 67       19.50      95.61      19103.48       479.03     479.03
============================================================================

WRONG WAY:
loan 19200 6 30 may 1967
============================================================================
 Loan amount: $19200.00     APR: 6.000%     Term: 30 years starting Jan 67

                      360 monthly payments of $115.11 

 Pay't   Date     Principal  Interest       Balance     Interest   Interest
  no.     due      Payment    Payment       of loan      (total)     (YTD)

    1   Jan 67       19.11      96.00      19180.89        96.00      96.00
    2   Feb 67       19.21      95.90      19161.68       191.90     191.90
    3   Mar 67       19.30      95.81      19142.38       287.71     287.71
    4   Apr 67       19.40      95.71      19122.98       383.42     383.42
    5   May 67       19.50      95.61      19103.48       479.03     479.03
=============================================================================

I modified the usage line in the code as a reminder.
--
charlie



More information about the Comp.sys.att mailing list