# Name: Jiaxin Lin
# MacID: linj33
# Student number : 1311752
# date: 2014/01/21


# futval.py
# A program to compute the value of an investment


print " This program calculates the futre value of an investment"

p= input (" Enter the number of initial principal: ")
r= input ("Enter the value of interest rate between 0 and 1: ")
n= input (" Enther the number of times the interest is compounded per year: ")
t = input (" Enther the number of years: ")
A1 = p* (1+ r/n)**(n*t)
print "A1= ", A1


ans=1
for i in range (0,n*t):
    ans= ans* (1+r/n)
    A2= ans*p
    print "A2= ", A2


import math
B = p*math.exp(r*t)
print " B= ",B

relativedifference1= abs(A1-A2)/A1*100
print " relativedifference1= ", relativedifference1

relativedifference2= abs(A1-B)/B*100
print " relativedifference2= ", relativedifference2



#Design Question
# yes, because n*t is in the range i, and i should be interger


# Test plan

# Test # 1
# INPUT: p=5, r=0.1,n=2,t=2
# ACTUAL OUTPUT : A1=6.07753125, A2=6.07753125,B=6.107013791,relativedifference1=0
#                 relativedifference2=-0.482765259
# EXPECTED OUTPUT :A1=  6.07753125, A2=  6.07753125 ,B=  6.1070137908,relativedifference1=  0.0
#                        relativedifference2=  0.482765256651
# RESULT :PASS

# Test #2
# INPUT: [5,0.25,0.5,4]
# EXPECTED OUTPUT : ERROR
# ACTUAL OUTPUT : ERROR
# RESULT: PASS


# Test #3
# INPUT: [10,0.2,5,0.3]
# EXPECTED OUTPUT : ERROR
# ACTUAL OUTPUT : ERROR
# RESULT: PASS

            
    
