For this assignment you will develop a depreciation calculator. Depreciation is an accounting concept and requires yearly cost allocations for purchases such as equipment and other material resources used in business. In other words, if a company purchases a piece of equipment (a car or truck would be one example) for $30,000 but expects to use that piece of equipment for several years, it cannot take the full expense of the item in the year it is purchased the expense must be portioned out over the life of the item.

The simplest form of depreciation is called straight line. In this form the same amount of expense is recorded each year. Depreciation expenses are always based on the original purchase cost of an item less any salvage value that is expected at the end of the useful life of the item. In straight line depreciation, the difference between cost and salvage value is just divided by the number of years of service expected. In other words, if our $30,000 truck is expected to be worth $5000 after 5 years of useful life, then the depreciation per year is (30000 - 5000) / 5 = $5000 per year. A straight line depreciation schedule would be:

Year Start Value Depreciation End Value
1 30,000 5,000 25,000
2 25,000 5,000 20,000
3 20,000 5,000 15,000
4 15,000 5,000 10,000
5 10,000 5,000 5,000

(For additional info on depreciation, see web sites such as http://en.wikipedia.org/wiki/Depreciation ).

The items always needed for the depreciation calculation: Cost, Salvage Value, and Life of Item

Develop a program to calculate straight-line annual depreciation for an asset, including the option to show a year-by-year schedule for the depreciation. In this program you will also ask for the name of the asset, so a sample run would look like this:

Welcome to the depreciation calculator!

Please enter the Asset Cost (0 to quit): 30000
Please enter the Salvage Value: 5000
Please enter the Asset Life (in years): 5
Please enter the Asset Description: Truck

Annual depreciation on the Truck, with a $30,000.00 asset value and a salvage value of $5,000.00, over a life of 5 years = $5,000.00 per year.

Would you like to see a complete schedule for the Truck (Y/N)? Y

Year Start Value Depreciation End Value
1 $30,000.00 $5,000.00 $25,000.00
2 $25,000.00 $5,000.00 $20,000.00
3 $20,000.00 $5,000.00 $15,000.00
4 $15,000.00 $5,000.00 $10,000.00
5 $10,000.00 $5,000.00 $ 5,000.00

Please enter another Asset Cost (0 to quit): 0
Thanks for using the depreciation calculator!

Note that the program loops to calculate as many assets as needed. Format the numeric values as currency, as shown above, but: we have not developed a technique for aligning the data in neat columns, so that is not a requirement of the exercise (but see the extra credit below).

For full credit you must:

1)Use variable type double for cost and salvage value, int for life, and String for description

2)Use globals where needed (i.e., where values must be available to all methods)

3)Minimize the amount of code in main() by using separate method calls, but include a loop so that multiple assets may be evaluated

4)Use separate get methods to obtain and validate the input values:

a.cost must be > 0

b.salvage value must be >= 0 and < cost

c.asset life must be > 0

d.also make sure illegal values dont crash the program

5)Use a separate method to calculate and return the annual depreciation value

6)Use a separate method to produce the output schedule (if requested by the user).

A sample starter program called Depreciation is included with the assignment, and it has a beginning structure for the main() method (note that errors will show in the starter project because the variables have not yet been defined). Download and unzip the starter, then complete the program as indicated above. Re-zip the completed netbeans project from the top-level folder and submit the zip file.

Part B: As noted above, the schedule you produce does not need to have neatly formatted columns. There are, however, some tools for doing this, one of which is a printf function of the System.out object. Investigate and implement the System.out.printf() function to align decimal points in the output columns of the schedule.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.