Thread: Schedule Loan program?

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    16

    Schedule Loan program?

    Suppose I have three parameters - Original Principal = 500, terms(in months) = 12, and Interest rate = 8.25. I want write a function that produce the following below. For that monthly payment, I can code it.
    For example. P = 500, i = (8.25/100)/12, and n = 12 (months).
    monthlypayment = P [(i(1 + i)^n / ((1 + i)^n) - 1]
    43.55 = monthlypayment.

    But what about Cumulative principal and cumulative interest rate? (Note: those aren't negative numbers, just - in front).

    Month Total Principal Interest Cum Princ Cum Int
    1 -$43.55 -$40.11 -$3.44 -$40.11 -$3.44
    2 -$43.55 -$40.39 -$3.16 -$80.50 -$6.60
    3 -$43.55 -$40.67 -$2.88 -$121.17 -$9.48
    4 -$43.55 -$40.95 -$2.60 -$162.12 -$12.09
    5 -$43.55 -$41.23 -$2.32 -$203.35 -$14.41
    6 -$43.55 -$41.51 -$2.04 -$244.86 -$16.45
    7 -$43.55 -$41.80 -$1.75 -$286.66 -$18.20
    8 -$43.55 -$42.09 -$1.47 -$328.75 -$19.67
    9 -$43.55 -$42.37 -$1.18 -$371.12 -$20.85
    10 -$43.55 -$42.67 -$0.89 -$413.79 -$21.73
    11 -$43.55 -$42.96 -$0.59 -$456.75 -$22.33
    12 -$43.55 -$43.25 -$0.30 -$500.00 -$22.62

    Above is an output from Excel, but I want to do the same in C++?

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    think about it this way: every time you have to remember a number, so does your program...

    a cumulative variable is no different than any other variable.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    1. Input your given-variables.

    2. Calculate the monthly payment using the formula. (One time only! Use the power function pow() from <cmath> )

    3. Initialize the starting balance (the loan amount)
    Initialize cumulative principal & comulative interest to zero.

    --------
    4. Start loop. (Loop once each month)

    5. Calculate the interest for this month's balance. (1/12th of the annual interest rate.)

    Update cumulative interest.

    6. Calculate the principal-paid, by subtracting the interest from the payment.

    Update cumulative principal.

    7. Calculate (and update) the next month's starting balance by subtracting the principal-paid from the starting balance.

    8. Repeat loop.
    --------

    EDIT -
    Are you asking about this?

    CumInterest = CumInterest + CurrentInterest // Update cumulative interest.

    Although that's not a valid equation, it is a valid C/C++ assignment statement. The value of the expression (or value) on the right gets assigned to the variable on the left. (And, you can't switch it around like an equation... The variable being updated must be on the left side.)
    Last edited by DougDbug; 04-22-2005 at 05:47 PM. Reason: Added cumulative shtuff.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM