<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS-->Here is a C# Application I developed for calculating the monthly payment for a loan, given the loan amount, interest rate and the loan period. <!-- Download Links -->
<!-- Article image -->
<!-- Add the rest of your HTML here -->I have used four labels, four text boxes and two buttons on a simple Windows form as shown in the screenshot. In addition, a status bar along the bottom of the form is used to describe what is expected in each text field.
The monthly payment needed to amortize a loan for a given interest rate and loan period can be calculated fairly easily using a financial calculator such as HP-12C or referring to tables in a Financial Accounting book. This small C# application uses the standard formulas to calculate the monthly payments quickly and easily. The user enters the present value of the loan amount in the first text box, followed by the annual interest rate and the number of payments for the loan. The Calculate button computes the monthly payment and displays the result in the fourth text box. Clicking the Exit button quits the application. Tool tips are also displayed when the mouse hovers over each text box. A timer control is used to display the right message in the status bar. The text boxes prevent non-numeric entry, by filtering out characters other than 0-9 and the decimal point. The user is not allowed to edit the fourth text box (Payment). See the event handler under the textBox1.KeyPress for details of how non-numeric keys are handled. The KeyPressEventHandler takes care of this. The calculation for monthly payments is performed by the static method calcPayment that is invoked by the click event of the Calculate button. The use of both the status bar and tooltips may appear to be an overkill. However, I left them both in simply to illustrate the use of the tooltips and the status bar messages for helping the user with data input. Comments are welcome.
I am a graduate engineer with over 20 years experience in engineering and computer programming. I have programmed in Fortran, Basic, TurboPascal,C, C++, Visual Basic, Java and now C#. I have developed and co-developed several commercial apps that are currently marketed for engineers in the Oil and Gas industry. I have been working with .NET and C# since the Beta 1 version. I am currently developing an online course and a 2 day Workshop in C#.