@dj2638/

JSDMathLib

Python 2.7

A library of simple and complex math functions and equations.

fork
loading
Files
  • main.py
main.py
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
36
37
38
39
import math
import sys
from sys import stdout

def writeln(out):
	stdout.write(out)
	stdout.write("\n")
	return
	
def write(out):
	stdout.write(out)
	return


class _CompoundInterest:
	def print_formula(self):
		formula = ["       /      r  \\ n t",
				   "A = P |  1 + ---  |",
				   "       \\     n  /",
				   "",
				   "A | Final Amount",
				   "P | Principle Deposit",
				   "r | Anual Interest Rate",
				   "n | Number of times interest if compounded each year",
				   "t | Total Time in Years"]
		for line in formula:
			writeln(line)
			
	def solvefor_A(self, principle, rate, n, time):
		A = 1 + (rate / n)
		A = pow(A, (n * time))
		A = principle * A
		return A

CompoundInterest = _CompoundInterest()
CompoundInterest.print_formula()
while True:
	writeln("")
	print(CompoundInterest.solvefor_A(input("P: "), input("r: "), input("n: "), input("t: ")))