Python Forum
Program calculating intrests - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Program calculating intrests (/thread-1440.html)



Program calculating intrests - the_werid_guy - Jan-03-2017

def money():
    capital = int(input('Input amount of money invested: '))
    percentage = float(input('Input percentage provided by bank: '))
    days = int(input('Input amount of days, 30 - month, 360 - year: '))
    capitalisation = int(input('Capital is capitalised how many times?: '))
    i = 0
    while i < capitalisation:
        profit = (capital * percentage * days/capitalisation)/36000
        capital = capital + profit
        i += 1
    print("You will have:", capital)
    again()
def again():
    calc_again = input('''Do you want to calculate again? Please type Y for YES or N for NO: ''')
    if calc_again.upper() == 'Y':
        money()
    elif calc_again.upper() == 'N':
        print('Thanks for launching.')
    else:
        print('Enter a valid answer')
        again()
money()
That's my code. If you assume that the percentage given by the bank is capitalised once a year it works fine, but if i try to capitalise it more often, it all goes wrong.  Did I mistake anything in code or i just went wrong way developing my idea? I'm new to programming and seeking for simple explanation. Thanks in advance!


RE: Program calculating intrests - stranac - Jan-03-2017

(Jan-03-2017, 04:43 PM)the_werid_guy Wrote: it all goes wrong
That's not really a good description of the problem.
Give us more details. Do you get an error (what is it)? Do you get wrong result (what did you get and what did you expect)?