I would like to introduce to you all my latest project plan which is to build a finance calculator to calculate various financier-related issues which include my previous solution to find the present and the future sum of money in it.
In this article, I will start building the application with the first mission, which is to create an application that will take the user inputs and then output the present or future sums of money, the formula to find the sum of money will be based on the previous solution which you can read on my previous article.
I will use wxPython to create the entire financier project, if you want to know more about this python’s third-party module you can either visit its homepage or read my previous wxPython articles about it!
Below is the entire python program used to create an approximate user interface that will accept the user inputs and then calculate the present and the future sum of money. This is more or less like a draft program which I will modify later as the project progresses before uploading it to GitHub for you all to enjoy! This project is a big project and this calculator will include various functions to do various financial calculations!
As you can see from above after you have entered the amounts of money, specify whether you want to find the present or future sum of money, entered the total interest period, and select the interest rate per interest period, the program will then go to work to find the result and displayed it in the form of message box (this is only a draft program thus the outcome will certainly not in the form of message box but instead in a more appropriate form later).
Below is the entire program, hope you will enjoy it.
import wx class CalPro(wx.App): def OnInit(self): self.the_frame = wx.Frame(None, -1) # create the top frame self.the_frame.Show(True) return True def OnButton(self, event): self.amout = int(self.amt.GetValue()) # get the amount entered self.year = int(self.n.GetValue()) # get the years entered self.percentage = self.combo1.GetValue() # get the percentage if self.percentage == "3%": self.pct = 0.03 elif self.percentage == "6%": self.pct = 0.06 elif self.percentage == "12%": self.pct = 0.12 else: self.pct = 0.16 self.present_or_future = self.chkbox1.GetValue() self.total = 0 if(self.present_or_future == True) : self.total = round(self.amout * pow((1 + self.pct), self.year), 2) else: self.total = round(self.amout / pow((1 + self.pct), self.year), 2) self.CreateMessageBox(self.present_or_future, self.percentage, self.year, self.total, self.amout) def CreateMessageBox(self, present_or_future, percentage, year, total, amount): self.message = "" if(present_or_future == True): self.message += "With " + percentage + " interest rate per interest period " + "you will receive " + "$" + str(total) + " at the end of " + str(year) + " interest period" + " if you invest " + "$" + str(amount) + " at this moment!" else: self.message += "With " + percentage + " interest rate per interest period " + "you will receive " + "$" + str(amount) + " at the end of " + str(year) + " interest period" + " if you invest " + "$" + str(total) + " at this moment!" wx.MessageBox(self.message, 'Present Future Value', wx.OK | wx.ICON_INFORMATION) def CreateWidgets(self): # create various widgets self.CreateButton() self.CreateCheckBoxes() self.CreateComboBox() self.CreateTextBoxes() def CreateComboBox(self): # create combo box cif = ["3%", "6%", "12%", "16%"] # compound interest factors self.percentLabel = wx.StaticText(parent=self.the_frame, id=15, label="Interest Rate : ", pos=wx.Point(10, 150), size=wx.Size(width=80, height=100), style=0, name="rate") self.combo1 = wx.ComboBox(parent=self.the_frame, id=3, value="3%", pos=wx.Point(90, 150), size=wx.Size(width=50, height=100), choices=cif, style=0, name="week day") def CreateButton(self): self.the_button = wx.Button(self.the_frame, id=1, label="Calculate", pos=wx.Point(150, 350), name="Hello!") self.the_button.Bind(wx.EVT_BUTTON, self.OnButton) def CreateCheckBoxes(self): self.chkbox1 = wx.CheckBox(self.the_frame, id=2, label="Present Sum", pos=wx.Point(190, 150), size=wx.Size(width=100, height=20), style=0, name="check1") def CreateTextBoxes(self): self.amtLabel = wx.StaticText(parent=self.the_frame, id=13, label="Amount : ", pos=wx.Point(10, 50), size=wx.Size(width=100, height=30), style=0, name="label") self.amt = wx.TextCtrl(parent=self.the_frame, id=20, value="", pos=wx.Point(65, 50)) self.nLabel = wx.StaticText(parent=self.the_frame, id=13, label="Interest Period : ", pos=wx.Point(200, 50), size=wx.Size(width=120, height=30), style=0, name="label") self.n = wx.TextCtrl(self.the_frame, id=21, value="", pos=wx.Point(290, 50), size=wx.Size(width=60, height=23)) wxapp = CalPro() wxapp.CreateWidgets() # initialise all widgets wxapp.MainLoop()
Now let us find the present and the future sum of money using this application.
1) Now let us try to enter the below parameters into the application, the present sum of money p is $600, the interest rate per interest period is 3% and the interest period is 3 as well. You will need to tick the Present Sum checkbox if the present sum of money is a known value.
Click on the calculate button below to display the result.
2) Let’s find the present sum of money you need to put into your bank account if you expected $500 inside your bank at the end of the first year with 6 percent annum bank interest. Since what you want now is to find the present sum of money when the future sum of money is a known amount then you will need to uncheck the Present Sum checkbox.
Click on the calculate button to display the result.
As per expected, the program did what it supposes to do which was to calculate the present and the future sum of money and presented it to the user!
I will continue to develop this application and when I have uploaded it to Github I will let you all know through this website.