Appreciation for Depreciation

Back in the day, computer programming courses offered predictable assignments. These were number-crunching exercises, which had little flash and, yes, were boring. Today you can plot graphics, manipulate sound, and explore the web with your code. Back then, you’d do something dull like calculate depreciation.

It’s still a worthy exercise! A depreciation calculation is a tame example that remains a challenging exercise, especially for beginners.

Depreciation is an accounting fiction that states how something your purchase — a capital item — loses its value over time. For nefarious tax purposes, you get to “write off” the decreased value of the item as an expense. That nonsense isn’t important to a programmer, but making the calculation is important.

As an example, suppose a business purchases a $10,000 copier. Each year, the value depreciates by 10 percent. The tax man had determined that the item can depreciate for 5 years, so what is its value each year? A program could show you such results like this:

Enter initial cost: $10000
Enter annual depreciation as a decimal: .10
Enter years to depreciate: 5

Depreciation Schedule
=====================
Year  0: $10000.00
Year  1: $9000.00
Year  2: $8100.00
Year  3: $7290.00
Year  4: $6561.00
Year  5: $5904.90

You type in 10000 for the $10,000 initial code. Type .10 for 10%. Then type 5 for the years. The code generates and outputs the Depreciation Schedule, as shown above. And as a programmer, you don’t need to worry about how a copier that still works in Year 4 is worth only $6,561.00 or what that even means to an accountant. That’s because:

Your job is to write the code that calculates and displays a depreciation schedule. Accept three items as input: The initial cost, the annual depreciation (which is a percentage) and the number of years to depreciate the item. Output the results in a table, as shown above, though you can get fancier if you so desire.

Click here to read my solution to this month’s Exercise.

Leave a Reply