Click here to Skip to main content
Click here to Skip to main content

Pocket PC Mortgage Calculator

, 26 Apr 2004
Rate this:
Please Sign up or sign in to vote.
A submission for the CodeProject April 2004 contest.

Figure 1 - MortCalc Input Pane

Figure 2 - MortCalc Summary Pane

Figure 3 - Bank's Mortgage calculator results

Introduction

This article presents a handy little Pocket PC application that calculates mortgage payment schedules and displays the results on a Pocket PC. It also allows the information to be saved to a text file for export or for printing.

It is a type of application that may be of great value to people in real estate or finance who need to run calculations of this sort when out in the field away from a desktop system or an internet connection.

It may also be quite useful for individuals to quickly run several different repayment scenarios when negotiating for a new mortgage or renewing an existing one. It is tempting to extend the term to the longest possible and to make the payments as small as possible when in this situation. This application demonstrates the large savings in interest cost over the life of a mortgage by using the opposite approach - shortening the amortization period by either selecting a slightly higher payment amount, or a more frequent re-payment schedule.

The main challenge that was presented in this project was to be able to concisely display large amounts of information that result from calculations of this sort. This was resolved by creating separate display panes in the main tabbed control. An input pane as shown above is used to accept all input values, to calculate initial re-payment amount, and optionally allow the use of an over-ridden actual payment amount. Once all the input has been entered, you can click on the summary pane to see the result of the calculation. If you want to see the re-payment progression, click on the details pane to see the year by year re-payment data. Finally, click on the report button to save all this information to a text file. The output file can be re-used for multiple calculations. It may then be exported to a desktop system for storage or printing to hard copy. And finally, a help pane is available with basic operating instructions.

Another challenge was to arrange the screen and code the input controls so that either the soft keyboard or stylus may be used to enter the input values conveniently and accurately.

Background

This implementation on a Pocket PC is just the latest incarnation of a program I wrote over 35 years ago. It was originally written in the Fortran language and targeted at a Honeywell H-200 mainframe computer. At the time I was a field engineer maintaining this class of big iron, and was curious to see how well and fast it could deal with floating point calculations. It also allowed me to try out the new realm of work known as computer programming.

The original program has over the years been ported and re-written many times in Pascal, C, C++, and now C# and run on everything from mainframes, mini-computers, home-built micro-computers, and finally on this little hand-held gem. Obviously, there are changes for each different implementation, but the computation algorithm and output presentation are very much the same as in the original Fortran version. Some of the variable names have been retained in their original six digit maximum lengths. (for sentimental reasons only)

This is my version of Hello World.

Using the code

Other than the code that calculates the re-payment amount, there is not very much complexity anywhere else. The DoInput() method makes sure all the required inputs are available and then does these two calculations:

// Calculate payment amount 
int_factr = ( Math.Pow( (double) ( ( rate / 100.0M ) / com ) 
  + 1.0, (double) ( 1.0M / ( pay_yr / com ) ) ) - 1.0 ); 
calc_pay = prin * (decimal) ( int_factr / ( 1.0 - ( 1.0 / 
  Math.Pow ( (double) ( ( rate / 100.0M ) / com ) + 1.0, 
    (double) ( amort * com ) ) ) ) ); 

"calc_pay" becomes the calculated re-payment amount and "int_factr" is an interest factor. These two values are then just applied re-iteratively in the detailed and summary calculations with simple basic arithmetic operations.

All the rest of the code is standard C# code that becomes boiler plate to deal with the user interface and formatting the output for presentation to the user.

The input controls use validating code to prevent any non-numeric values appearing in the input, and to restrict the length of input. These were specifically targetted for ease of use with the soft keyboard and the stylus.

Points of Interest

This project gave me my first taste of programming for a Pocket PC. One problem I ran into right away was that my development system is vastly underpowered for running an emulator or remote de-bugging, and therefore the turnaround time for development and testing became intolerable. I was able to work around this very easily by just commenting out the lines defining the inputPanel control, and then using the standalone .NET de-bugger to run the compiled executable locally on my desktop. Once everything was working well enough, I would re-enable the inputPanel control, re-compile and deploy to the emulator for final testing. (Hint - remove any compact framework specific controls, and you are back to a plain vanilla desktop Winforms application)

History

This is the final version for the Pocket PC 2002 platform.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

foobert
Web Developer
Canada Canada
Old dog learning new tricks!

Comments and Discussions

 
GeneralGreat! PinmemberMember 62539411-Dec-07 5:03 
GeneralGreat! Thank you very much. PinmemberMember 62539411-Dec-07 5:02 
QuestionNot that good yet... PinmemberJollyRoger24-Mar-06 17:56 
GeneralMissing file Pinmembermtr36913-Aug-05 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 27 Apr 2004
Article Copyright 2004 by foobert
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid