Well, as complex as you want to make it!
Start by estimating time taken to create, test and debug the application. Decide what you want to charge per hour.
Say you took 100 hours at $10 per hour. The program has cost you $1000 plus expenses (cost of running pc, printing, media etc. Don't overlook these expenses!). Don't forget time and expenditure on documentation, manuals, etc.
So allowing for expenses, you have 'invested' say $1100 on the project.
You need to sell the program. If you sell 100 copies at $11 a throw, you have covered your investment, and no more. The same applies if you sell 11 copies at $100 a throw.
Determine how many copies you are likely to sell. Divide your investment by that figure. Say you know for a fact you can shift 4 copies straight off, that means you should be selling for about $550 a copy to break even. Now, apply the 'Walmart Principle'. If you sell for half that figure, will you double (or better) the number of customers? If not, then why not?
Having worked out a price per copy, add a profit margin, say 25%. Then repeat the above process.
Remember 10% profit on 100 items is better than 25% profit on 30 items. Do your market research before you even commit yourself to a single byte of code!
If you work the figures correctly, you should find a price point where your costs are recovered in a reasonable time-frame and any additional sales are profit.
Do you then re-invest this profit towards ongoing development, or use the money to live on? You have asked a question to which there is no simple answer!
This leaves out any discussion on 'end user value', which TheChas has mentioned...incorporating this into the equation increases the variables and makes the calculation more complex but will allow you to make a better judgement on selling price.
An alternative...as how much they are willing to pay for the job. Then, are you prepared to do it for that price....use your formula in reverse to see how much time you can allocate to the job before you make a loss. If it is not then viable, drop the project!