forked from CodeMaster7000/Compound-Interest-Calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompound Interest Calculator.py
54 lines (44 loc) · 1.78 KB
/
Compound Interest Calculator.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from tkinter import *
def clear_all() :
principle_field.delete(0, END)
rate_field.delete(0, END)
time_field.delete(0, END)
compound_field.delete(0, END)
principle_field.focus_set()
def calculate_compoundinterest():
principle = int(principle_field.get())
rate = float(rate_field.get())
time = int(time_field.get())
compoundinterest = principle * (pow((1 + rate / 100), time))
compound_field.insert(10, compoundinterest)
if __name__ == "__main__" :
root = Tk()
root.geometry("310x250")
root.title("Compound Interest Calculator")
label1 = Label(root, text = "Principle Value",
fg = 'black', bg = 'orange')
label2 = Label(root, text = "Rate (%)",
fg = 'black', bg = 'orange')
label3 = Label(root, text = "Time (years)",
fg = 'black', bg = 'orange')
label4 = Label(root, text = "Compound Interest",
fg = 'black', bg = 'orange')
label1.grid(row = 1, column = 0, padx = 10, pady = 10)
label2.grid(row = 2, column = 0, padx = 10, pady = 10)
label3.grid(row = 3, column = 0, padx = 10, pady = 10)
label4.grid(row = 5, column = 0, padx = 10, pady = 10)
principle_field = Entry(root)
rate_field = Entry(root)
time_field = Entry(root)
compound_field = Entry(root)
principle_field.grid(row = 1, column = 1, padx = 10, pady = 10)
rate_field.grid(row = 2, column = 1, padx = 10, pady = 10)
time_field.grid(row = 3, column = 1, padx = 10, pady = 10)
compound_field.grid(row = 5, column = 1, padx = 10, pady = 10)
button1 = Button(root, text = "Submit", bg = "orange",
fg = "black", command = calculate_compoundinterest)
button2 = Button(root, text = "Clear", bg = "orange",
fg = "black", command = clear_all)
button1.grid(row = 4, column = 1, pady = 10)
button2.grid(row = 6, column = 1, pady = 10)
root.mainloop()