{"id":1784,"date":"2016-03-01T00:01:20","date_gmt":"2016-03-01T08:01:20","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=1784"},"modified":"2016-03-08T11:47:42","modified_gmt":"2016-03-08T19:47:42","slug":"appreciation-for-depreciation","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=1784","title":{"rendered":"Appreciation for Depreciation"},"content":{"rendered":"<p>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&#8217;d do something dull like calculate depreciation.<br \/>\n<!--more--><br \/>\nIt&#8217;s still a worthy exercise! A depreciation calculation is a tame example that remains a challenging exercise, especially for beginners.<\/p>\n<p>Depreciation is an accounting fiction that states how something your purchase &mdash; a capital item &mdash; loses its value over time. For nefarious tax purposes, you get to &#8220;write off&#8221; the decreased value of the item as an expense. That nonsense isn&#8217;t important to a programmer, but making the calculation is important.<\/p>\n<p>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:<\/p>\n<pre><code>Enter initial cost: $10000\r\nEnter annual depreciation as a decimal: .10\r\nEnter years to depreciate: 5\r\n\r\nDepreciation Schedule\r\n=====================\r\nYear  0: $10000.00\r\nYear  1: $9000.00\r\nYear  2: $8100.00\r\nYear  3: $7290.00\r\nYear  4: $6561.00\r\nYear  5: $5904.90<\/code><\/pre>\n<p>You type in <strong>10000<\/strong> for the $10,000 initial code. Type <strong>.10<\/strong> for 10%. Then type <strong>5<\/strong> for the years. The code generates and outputs the Depreciation Schedule, as shown above. And as a programmer, you don&#8217;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&#8217;s because:<\/p>\n<p>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.<\/p>\n<p><a href=\"http:\/\/c-for-dummies.com\/blog\/?p=1796\">Click here<\/a> to read my solution to this month&#8217;s Exercise.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Finally: A traditional, boring programming assignment! <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=1784\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1784","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1784"}],"version-history":[{"count":4,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1784\/revisions"}],"predecessor-version":[{"id":1813,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1784\/revisions\/1813"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}