Purpose of Exercise: to Understand and Implement the Control Structure - Looping

Total Page:16

File Type:pdf, Size:1020Kb

Purpose of Exercise: to Understand and Implement the Control Structure - Looping

Purpose of exercise: To understand and implement the control structure - Looping.

Write a class called Depreciation to compute the depreciation schedules of an asset. Use the two accounting methods: - the straight-line depreciation method, and - the sum-of-digits method of depreciation.

The algorithm for the straight-line method is simple; the amount to be depreciated is divided evenly over the specified number of years. Suppose that you have an asset of original value of $1,000.00 to be depreciated over 3 years. For example, the following table shows the depreciation and book value of the asset.

YEAR DEPRECIATION DEPRECIATION ACCUMULATED ASSET RATE AMOUNT DEPRECIATION VALUE 1 1/3 333.33 333.33 666.67 2 1/3 333.33 666.67 333.33 3 1/3 333.33 1000.00 0.00

The sum-of-the-digits work as follows: Suppose that you have an asset of original value $1,000.00 to be depreciated over 3 years. For example, the following table shows the depreciation and book value of the asset.

YEAR DEPRECIATION DEPRECIATION ACCUMULATED ASSET RATE AMOUNT DEPRECIATION VALUE 1 3/6 500 .00 500.00 500.00 2 2/6 333.33 833.33 166.67 3 1/6 166.67 1000.00 0.00

Your program must have the following in order to receive full credits:

1) showMenu: that displays the following menu when called:

1 - Straight Line 2 - Sum of Years Digits 0 – Quit 2) displayHeader: displays the table's headers 3) straightLine : displays the straight line method table with appropriate values based on the given asset. 4) sumOfDigits : displays the sum-of-digits method table with appropriate values based on the given asset.

Write a driver class called TestDepreciation. Use the following data to test the class depreciation.

Test your program with the following set of data; a) Amount: $10000.0 years: 10 method: straight line b) Amount: $20000.0 years: 10 method: sum of digits

Note: Use a do .. while loop to control the menu, but while loops to control the methods.

1

Recommended publications