-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompound_interest_calculator.py
More file actions
35 lines (31 loc) · 1.48 KB
/
compound_interest_calculator.py
File metadata and controls
35 lines (31 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#Calcute the total compound interest
print("\t\t\t···································")
print("\t\t\t:··Compound Interest Calculator··:")
print("\t\t\t···································")
print("\nInterest Period:\n")
Pi = {1:'1-Months.',
2:'2-Years.'}
for value in Pi:
print(Pi[value])
print("\t\t\t___________________________________")
Pi = int(input("\nChoose an interest period of time: "))
if Pi == 1:
print("\nYou have chosen to calculate your compound interest monthly.")
C = float(input("\nEnter your initial investment (USD): "))
i = float(input("\nEnter your interest rate (%): "))
n = float(input("\nEnter your interest period of time (months): "))
Cfinal = C*(1+(i/100))**n
print(f"\nYou have made an initial investment of {C} USD.")
print(f"\nYou have chosen an interest rate of {i}%.")
print(f"\nYou obtain {Cfinal:.2f} USD after {n} months.")
elif Pi == 2:
print("\nYou have chosen to calculate your compound interest annually.")
C = float(input("\nEnter your initial investment (USD): "))
i = float(input("\nEnter your interest rate (%): "))
n = float(input("\nEnter your interest period of time (years): "))
Cfinal = C*(1+(i/100))**n
print(f"\nYou have made an initial investment of {C} USD.")
print(f"\nYou have chosen an interest rate of {i}%.")
print(f"\nYou obtain {Cfinal:.2f} USD after {n} years.")
else:
print("\nERROR: WRONG DATA...")