本文介绍了如何计算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;
}

推荐答案

#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;
}


这篇关于如何计算c ++中的双倍下降余额?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 00:02