Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Member unclekyky's Avatar
    Join Date
    Sep 2003
    Posts
    62
    Member #
    2938
    Lets say i have a lettle script that pretends it is a bank. I can deposit or withdraw money. How can i make it have a 5% interest each day? So one day I have put in 100 dollars and the next there should be 105 dollars. I am open to anyway to do this.

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    [searchweb]amortization algorithm[/searchweb]

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Actually, scratch that. You're going to have to store the following info in your database"

    account_types
    --------
    account_type_id
    interest_rate
    compound
    minimum_balance

    accounts
    --------
    user_id
    account_type
    balance
    balance_as_of (date)

    transactions
    --------
    account_id
    amount
    date

    To find out the balance at any given moment, you will have to compound each transaction by the interest rate per unit of time elapsed (e.g. day). Of course, you could add some complexity to the system by maintaining a running total (which would then increase performance, but would also require some periodic daemon execution).

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Run a cron job daily?

    Select all of the values from the database, then use Money in account * 1.05 and have all the new values entered back in. However, if the database is large then it will take some time to process.
    JR

  6. #5
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    I guess you could also get the increase by adding a timestamp column to the table containing the amount.

    Every time you alter data in a row, a new timestamp (current date) will automatically be generated. This way you could extract the amount of days that has passed since the last time you extracted/inserted data into that row, and use that amount of days to create a loop iterating a calculation of 1.05 for the amount of days since the data last was altered.
    The final result is displayed and reinserted into the table, thus generating a new current timestamp to be used the next time the data is displayed.
    S. Rosland

  7. #6
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    rosland, that's exactly what I said to do... only using different words to explain it.

  8. #7
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Umm.. go take pre-algebra. There's a simple formula that I have written down somewhere that'll calculate it for any amount of days. There's all kinds of formulas around intrest..
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  9. #8
    Member unclekyky's Avatar
    Join Date
    Sep 2003
    Posts
    62
    Member #
    2938
    i have it figured out now thanks for the help guys. BTW i am a freshmen in highschool and am in Algebra 2

  10. #9
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Transio, I see that now.

    You sketched out a DB setup for a complete accounting system including transactions. It got a bit too complex for me, so I missed out/didn't understand the:
    ..you will have to compound each transaction by the interest rate per unit of time elapsed (e.g. day)..
    At the time, it appeared you and JR where talking about some daemon/cron functionality while I thought I suggested a simpler setup (for the calculation of interest rate)

    Didn't mean to repeat your post. :cross-eyed:
    S. Rosland

  11. #10
    Member Seraph's Avatar
    Join Date
    Sep 2003
    Posts
    81
    Member #
    3090
    I just learned that lol

    Ammount = Initial x (1+ (percentage/times per year ))^(times per year x number of years)

    for coninually compounded intrest its

    ammount = initial x e^(percentage x number of years)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:16 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com