Financial calculation using .NET Part 1:- How much will I get after X years?

Questpond
Posted by in ASP.NET category on for Advance level | Views : 3979 red flag

In finance world many times we need to calculate general financial calculation like interest calculation, regression analysis, internal rate of return etc. .NET does not provide readymade functions for these regular financial functionalities. Building these functionalities from scratch is not a big thing but testing it end to end with different scenarios is a challenge. We will try to understand how we can reuse 'Financial' classes from Microsoft.VisualBasic namespace. These functions are time tested and you do not need to code from scratch.

In this part we will understand how we can calculate the future value for a given rate of interest, period and monthly invested amount.

I have uploaded a sample source code which has a simple UI to calculate the future value.


 Download source code for Financial calculation using .NET Part 1:- How much will I get after X years?

Title:        Financial Calculation using .net - Part 1  How much will I get after X months ?
Author:      Shivprasad Koirala 
Email:       shiv_koirala@yahoo.com
Language:    .net Interview Questions
Level:       Beginner
Description: Financial Calculation using .net - Part 1

Financial Calculation using .net


Introduction

Understanding the future value fundamental
 

Introduction

 

In finance world many times we need to calculate general financial calculation like interest calculation, regression analysis, internal rate of return etc. .NET does not provide readymade functions for these regular financial functionalities. Building these functionalities from scratch is not a big thing but testing it end to end with different scenarios is a challenge. We will try to understand how we can reuse 'Financial' classes from Microsoft.VisualBasic namespace. These functions are time tested and you do not need to code from scratch.

In this part we will understand how we can calculate the future value for a given rate of interest, period and monthly invested amount.

I have uploaded a sample source code which has a simple UI to calculate the future value.

I have been writing and recording lot of architecture related videos on design patterns, UML, FPA estimation, C# projects etc you can watch my videos on http://www.questpond.com  

 

Understanding the future value fundamental

 

First let’s understand how future values are calculated in finance domain. Let’s say you have decided to invest for two year in some scheme. Let’s say the amount is 1000 (I am not thinking in terms of INR, $ or pounds) at rate of interest of 10%.  So for the first month you will invest 1000 with 10% interest in the second month you will get 1100. Now in second month you invest 1000, so the total is 1000 + 1100. Now the rate of interest on 2100 is 210. So after two months you will get 2310.

The above calculation is nothing but future value calculation. This is available as a readymade function in ‘Microsoft.VisualBasic’ namespace. Once you import the name space you will get a ‘Financial’ static class which has a ‘FV’ function. This function takes in rate of interest , number of months  and amount per month. Once we give this it calculates the value you will get after the defined period. I have wrapped the ‘Financial.FV’ function in a class ‘ClsFutureValue’.

 

you can  download the source code attached with this article to see how the FV function works. Below is the screen shot of the sample project.

 

 

 

Page copy protected against web site content infringement by Copyscape

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)