Click here to Skip to main content
15,895,787 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include<iostream>
#include<string>

using namespace std;

int main(){
	double asset_cost, salvage_val, deprec;
	float percentage, rate, nextyear;
	int year = 10, i; //years
	
	cout<<"Asset cost: ";
	cin>>asset_cost;
	
	cout<<"Salvage value: ";
	cin>>salvage_val;
	
	
	for(i = 1; i<10 ; i++){
		deprec = 2 * asset_cost/year;
		cout<<deprec<<endl;
	}
	return 0;
}
Posted
Updated 28-Jul-14 20:58pm
v3

1 solution

According to this page: "Double Declining Balance Method Depreciation Calculator"[^], you have

C++
#include<iostream>
#include<string>
using namespace std;

int main()
{
        double asset_cost, salvage_val, deprec;
        double percentage, acc_deprec;
        const int YEARS = 10;


        cout<<"Asset cost: ";
        cin>>asset_cost;

        cout<<"Salvage value: ";
        cin>>salvage_val;

        percentage = 100.0 / YEARS;
        cout << "straight-line depreciation percentage " << percentage << endl;


        acc_deprec = 0.0;

        for(int y = 1; y <= 10 ; y++)
        {
                deprec = 2 * percentage / 100.0 * (asset_cost - acc_deprec);
                acc_deprec += deprec;
                cout<<deprec<<endl;
        }
        return 0;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900