Sure, I can help you with that. Here is a simple Fortran program that calculates the depreciation expense and accumulated depreciation for each year based on the initial cost, salvage value, and useful life of an asset.
program DepreciationCalculator
implicit none
double precision :: initialCost, salvageValue, usefulLife
double precision :: depreciationExpense, accumulatedDepreciation
integer :: year
! Get user input
print *, "Enter the initial cost of the asset:"
read *, initialCost
print *, "Enter the salvage value of the asset:"
read *, salvageValue
print *, "Enter the useful life of the asset (in years):"
read *, usefulLife
! Initialize accumulatedDepreciation
accumulatedDepreciation = 0.0
! Print header
print '(A15, A25, A25)', "Year", "Depreciation Expense", "Accumulated Depreciation"
! Calculate and print depreciation for each year
do year = 1, int(usefulLife)
depreciationExpense = (initialCost - salvageValue) / usefulLife
accumulatedDepreciation = accumulatedDepreciation + depreciationExpense
print '(I15, F25.2, F25.2)', year, depreciationExpense, accumulatedDepreciation
end do
end program DepreciationCalculator
This program first prompts the user to enter the initial cost, salvage value, and useful life of the asset. It then calculates the depreciation expense for each year and the accumulated depreciation up to that year. The results are printed in a table with columns for the year, depreciation expense, and accumulated depreciation. All values are printed with two decimal places for precision. Please note that this program uses straight-line depreciation, which is the simplest and most commonly used method. It assumes that the asset loses an equal amount of value each year. If you need a different depreciation method, the calculation of depreciationExpense would need to be adjusted accordingly.
By Bing Copilot
Sure, I can help you with that. Here is a simple Fortran program that calculates the depreciation expense and accumulated depreciation for each year based on the initial cost, salvage value, and useful life of an asset.
This program first prompts the user to enter the initial cost, salvage value, and useful life of the asset. It then calculates the depreciation expense for each year and the accumulated depreciation up to that year. The results are printed in a table with columns for the year, depreciation expense, and accumulated depreciation. All values are printed with two decimal places for precision. Please note that this program uses straight-line depreciation, which is the simplest and most commonly used method. It assumes that the asset loses an equal amount of value each year. If you need a different depreciation method, the calculation of
depreciationExpense
would need to be adjusted accordingly.