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 computer 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 computing equipment will have depreciated $150,000 over the 5-year period.
The calculation of depreciation tables that display the value lost in each of several years is an important accounting problem, and there are several ways of calculating depreciation.
Straight-line method - the amount to be depreciated is divided evenly over the specified number of years. For example, straight-line depreciation of $150,000 over a 5-year period gives an annual depreciation of 150000/5 = 30000. The table generated would look like this.
Year Depreciation 1 30000 2 30000 3 30000 4 30000 5 30000
Sum-of-the-years-digits method - To depreciate $150,000 over 5 years using this method first calculate the "sum of the years" 1 + 2 + 3 + 4 + 5 = 15. Multiply the amount to depreciate by the series of fractions generated below in the calculations column.
depreciation = n/sum * amount
5/15 * 150000 = 50000
4/15 * 150000 = 40000
3/15 * 150000 = 30000
2/15 * 150000 = 20000
1/15 * 150000 = 10000
The table generated would look like this.
Double-declining balance method - In this method, if an amount is to be depreciated over n years, 2/n times the undepreciated balance is depreciated annually. For example, in the depreciation of $150,000 over a 5-year period using this method, 2/5 * $150,000 = $60,000 would be depreciated the first year, leaving an undepreciated balance $90,000. In the second year, 2/5 * $90,000 = $36,000 would be depreciated, leaving an undepreciated balance of $54,000. Since only a fraction of the remaining balance is depreciated in each year, the entire amount will never be depreciated. Consequently, on the last year, depreciate all of the amount remaining.
Year Depreciation 1 50000 2 40000 3 30000 4 20000 5 10000
150000 * 2/5 = 60000, leaving an undepreciated balance of 90000.
90000 * 2/5 = 36000, leaving an undepreciated balance of 54000.
54000 * 2/5 = 21600, leaving an undepreciated balance of 32400.
32400 * 2/5 = 12960, leaving an undepreciated balance of 19440.
The entire remaining balance of 19440 is depreciated.
The table generated would look like this.
Year Depreciation 1 60000 2 36000 3 21600 4 12960 5 19440
/* Instance Fields */
private int myNumYears; // The number of years to depreciate
private double myAmount; // The amount to depreciate
/* Constructor */
public Depreciation(double amount, int numYears)
/* Methods */
/* Returns the number of years to depreciate */
public int getNumYears()
/* Returns the amount to depreciate */
public double getAmount()
/* Calculates and returns the sum where sum = 1 + 2 + ... + myNumYears
You MUST use a while loop to do your calculation
*/
private double sumYears()
/* Calculates and prints the table showing the year and amount of
depreciation for that year. See explanation and chart above.
You MUST use a for loop to do your calculations.
Algorithm:
1. Calculate the sum by calling the private method sumYears()
2. Assign myNumYears to a local variable n.
3. For year ranging from 1 through myNumYears do the following
a. Calculate the depreciation amount
b. Display year and depreciation amount
c. Decrement n
*/
public void printSumOfYearsTable()
/* This method calculates and prints the table showing the year and
amount of depreciation for that year. See explanation and chart
above. You may use any loop for the calculations.
*/
public void printStraightLineTable()
/* This method calculates and prints the table showing the year and
amount of depreciation for that year. See explanation and chart
above. You may use any loop for the calculations.
Algorithm:
1. calculate the value of the fraction as a double by dividing
2.0 by the number of years to depreciate.
2. Store the amount to depreciate into a local variable named
undepreciatedBalance
3. For year ranging from 1 through myNumYears -1 do the
Following.
a. Determine the amount to depreciate
b. Display the year and the amount to depreciate
c. Update the undepreciatedBalance
4. Display the last year and the amount remaining to depreciate
*/
public void printDoubleDecliningBalanceTable()
Use a do-while loop to ask the user if they would like to continue. In this loop do the following.