A new Simple Interest Calculator

Here it is.

--This was made by Adam9812. It is public domain.

--Interest Calculator 1.9.1

function setup()
   print("Principle: Starting Number")
   print("Rate: Rate interest is added or subtracted per year.")
   print("Time: Time passed in Years.")
   print("Simple: Whether simple or compound interest is calculated.")
   print("Compoundrate: The amount of time interest is compounded per year.(Only matters if simple is false)")
   print("Interest: Amount of added interest")

   interest = 0
   parameter.number("principle",.01,10000,1)
   parameter.number("rate",.01,1,.5)
   parameter.number("time",1,100,5)
   parameter.boolean("simple",true)
   parameter.number("compoundrate",1,12,1)

   parameter.watch("interest")

end

function draw()
    background(192, 192, 209, 255)
    if simple then
        interest = principle * rate * time
    else
        interest = principle * ((1 + rate/compoundrate) ^ (compoundrate* time) - 1)
    end
    fill(0, 0, 0, 255)
    font("AmericanTypewriter-Light")
    fontSize(90)
    str=string.format("Total: %.2f",principle+interest)
    text(str,WIDTH/2,HEIGHT - 90)
end

@dave1707 that link has some permission problems :wink:
@Adam9812 nice job :slight_smile:

Here is another version. The text is way smaller so it won’t go off the page when you mess around with the numbers on compound mode.

--This was made by Adam9812. It is public domain.

--Interest Calculator 1.9.2

function setup()
   print("Principle: Starting Number")
   print("Rate: Rate interest is added or subtracted per year.")
   print("Time: Time passed in Years.")
   print("Simple: Whether simple or compound interest is calculated.")
   print("Compoundrate: The amount of time interest is compounded per year.(Only matters if simple is false)")
   print("Interest: Amount of added interest")

   interest = 0
   parameter.number("principle",.01,10000,1)
   parameter.number("rate",.01,1,.5)
   parameter.number("time",1,100,5)
   parameter.boolean("simple",true)
   parameter.number("compoundrate",1,12,1)

   parameter.watch("interest")

end

function draw()
    background(192, 192, 209, 255)
    if simple then
        interest = principle * rate * time
    else
        interest = principle * ((1 + rate/compoundrate) ^ (compoundrate* time) - 1)
    end
    fill(0, 0, 0, 255)
    font("AmericanTypewriter-Light")
    fontSize(28)
    str=string.format("Total: %.2f",principle+interest)
    text(str,WIDTH/2,HEIGHT - 90)
end