All projects and laboratories will be submitted electronically through webCT. Zip up your entire project directory to submit as the source. (Right click on the project folder and follow the SentTo link.) The project directory should include the following:
Depreciation is a decrease in the value over time of some asset due to wear and tear, decay, declining price, and so on. For example, suppose that a company purchases a new comuter system for $200,000 that will serve its needs for 5 years. After that time it can be sold at an estimated price of $50,000. Thus, the value of the computer equipment will have depreciated $150,000 over the 5-year period. A common method of calculating depreciation is the sum of the years digits method. To illustrate it, consider again depreciating $150,000 over a 5-year period. We first calculate the sum of the years 1+2+3+4+5 = 15.
In the first year, 5/15 * 150000 = 50,000 is depreciated.
In the second year, 4/15 * 150000 = 40,000 is depreciated and
so on, giving the following depreciation table:
| Year | Depreciation |
|---|---|
| 1 | 50,000 |
| 2 | 40,000 |
| 3 | 30,000 |
| 4 | 20,000 |
| 5 | 10,000 |
Write a class Depreciation that stores the original cost of the item, the final value after years used and the number of years to depreciate. Include the usual accessor methods double getOriginalCost(), double getFinalValue() and int getYearsDepreciated(). You should also include a method void printDepreciationChart() that prints a chart similar to the one in the example. Include a private helper method private int sumYears() that returns the sum of the years including the final year. You will use this in the printDepreciationChart method.
Test your class with the data above and one other example. Use a do-while in the main method along with input from the keyboard.