Python Annuity Calculator

For the discussion of Perl, Python, Ruby, and PHP and other interpreted languages.

Python Annuity Calculator

Post by Ajax478 on Wed Apr 22, 2009 8:11 pm
([msg=22333]see Python Annuity Calculator[/msg])

Here is my first program in python. It is a annuity calculator for a future value annuity. I feel so good so now I get my annuity homework done like that with out a calc :)

Code: Select all


def AnnuityForm():
   
    principle=input("Please Enter Your Principle(Must Contain Cents): ")
    time=input("Please Enter How Long The Annuity Is: ")
    interest=input("Please Enter Your Interest Rate: ")
    tcompounded=input("Please Enter The Amount of Times It Is Compounded A Year: ")

    #Configuring n and i for principle forumla

    interest=interest/100.00
    interest=interest/tcompounded
    n=tcompounded*time

    #The principle formula

    part1=(1.00+interest)**n
    part2=part1-1.00
    part3=part2/interest
    total=part3*principle

    #Amount of money deposited
   
    deposited=principle*time*tcompounded

    #Total interest gained

    ttlinterest=total-deposited
   
    print ""
    print "Your final amount is $",total
    print ""
    print "The amount you deposited is $",deposited
    print ""
    print "The amount of interest you gained is $",ttlinterest
    print ""
    print ""
    AnnuityForm()


AnnuityForm()
There are 10 kinds of people in this world:

People who understand binary
People who don't
User avatar
Ajax478
New User
New User
 
Posts: 10
Joined: Sat Apr 11, 2009 7:33 pm
Blog: View Blog (0)


Re: Python Annuity Calculator

Post by YayPython on Wed Apr 22, 2009 8:40 pm
([msg=22335]see Re: Python Annuity Calculator[/msg])

You don't really need to put it all in a function, but it still works.
User avatar
YayPython
Experienced User
Experienced User
 
Posts: 50
Joined: Sat Jan 31, 2009 11:05 am
Blog: View Blog (0)


Re: Python Annuity Calculator

Post by Ajax478 on Thu Apr 23, 2009 6:17 am
([msg=22351]see Re: Python Annuity Calculator[/msg])

Well thats only because I wanted it to repeat because when I have to put in multiple problems one after another. If there is another way of doing that without functions please tell me thank you.
There are 10 kinds of people in this world:

People who understand binary
People who don't
User avatar
Ajax478
New User
New User
 
Posts: 10
Joined: Sat Apr 11, 2009 7:33 pm
Blog: View Blog (0)


Re: Python Annuity Calculator

Post by mischief on Thu Apr 23, 2009 7:37 am
([msg=22356]see Re: Python Annuity Calculator[/msg])

you can do it with some sort of loop.

you could set it up like this (psuedocode, i don't know python)

Code: Select all
function Enterdata()
{
// enter data here?
}

while(true)
// keep looping until killed
{
EnterData()
// possibly ask user if they want to enter data again
}


the way i believe you're doing it is a crude form of recursion, which is kinda bad practice.
The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you freed.
--Buddha
User avatar
mischief
Poster
Poster
 
Posts: 355
Joined: Wed Jan 07, 2009 4:16 pm
Blog: View Blog (0)


Re: Python Annuity Calculator

Post by Ajax478 on Thu Apr 23, 2009 3:14 pm
([msg=22392]see Re: Python Annuity Calculator[/msg])

Ah I see. Thanks guys. It works right now so I'll use it becuase I still need to do homework XD. But I will fix it later.
There are 10 kinds of people in this world:

People who understand binary
People who don't
User avatar
Ajax478
New User
New User
 
Posts: 10
Joined: Sat Apr 11, 2009 7:33 pm
Blog: View Blog (0)



Return to Interpreted Languages

Who is online

Users browsing this forum: No registered users and 0 guests