can anyone figure out and see if this calculation is correct?
I was attempting to do this depreciation in 3 ways: Single-Line, double decline, and the sum of years, two out of 3 work, the sum of years seems to not function correctly, it is possible that anyone can take a look at this and see if this is correct? I would appreciate it:
int sum_of_yrs(int amt, int yrs)
{
double deccurval, decanndep, yrcnt, count, yr, anndep, curval;
double intcurval, intanndep;
curval = amt;
yrcnt = 0;
for (count = 0; count <= yrs; count++)
{
yrcnt = yrcnt + (yrs - count);
}
for (yr = 1; yr <= 10; yr++)
{
anndep = ((yrs-(yr-1))/yrcnt) * amt;
intanndep = anndep;
decanndep = anndep - intanndep;
curval = curval - anndep;
intcurval = curval;
deccurval = curval - intcurval;
cout << endl << setw(4) << setprecision(0) << yr << setw(10) << fixed << setprecision(3) << intanndep << setw(15) << intcurval << endl;
}