Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please HELP! Build a depreciation calculator using C++, follow below directions,

ID: 3858549 • Letter: P

Question

Please HELP!

Build a depreciation calculator using C++, follow below directions, under directons is my current C++ coding done in VS:

Any assistance writtion out is appreciated!

Modify your Asset class so that it is capable of calculating ‘Double Declining’ depreciation as well as straight line. This will require you to have an additional set of return methods: getDDDep(y), getDDBBal(y), and getDDEBal(y) for returning the double declining depreciation for any year ‘y’. The Annual Depreciation return function will now be overloaded as getAnnualDep(y) since the double-declining depreciation changes from year-to-year. The main control program will also, of course, need to ask the user which type of depreciation schedule is desired (Straight-line or Double

Declining).

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

The annual depreciation allowance on a $30,000.00 asset with a salvage value of $5,000.00 and a life of 5 years = $5,000.00 per year under straight line or $12,000.00 first year depreciation under double-declining.

Would you like to see a complete schedule for Straight-Line, DDL, or Neither? (S/D/N)? D

Year    Start Value      Depreciation    End Value

1         30,000.00        12,000.00         18,000.00

2         18,000.00            7,200.00         10,800.00

3         10,800.00            5,000.00           5,800.00

4         6,480.00               800.00           5,000.00

5                  0.00                   0.00           5,000.00

Please enter the Asset Cost (0 to quit): 0

Thanks for using the depreciation calculator!

Notes on Double Declining depreciation:

In this alternate method, you still use purchase price and salvage value, but the depreciation calculated each year is at twice the rate of straight line (but not exactly twice the amount): the catch here is that the calculation takes the straight-line rate doubles it, and then applies that rate to the previous-year’s ending balance. Typically, at some point the double-declining method will produce yearly depreciation amounts below straight line – but instead of continuing with the declining method, at that point the straight line amount is used instead. Using our example, we first see that the straight line method = 20% per year (100% divided by 5 years); the double-declining method would thus be 40% per year – but based on the changing ending asset values in each year. Thus, a ‘pure’ double-declining schedule would be:

            Year    Start Value      Depreciation                            End Value

            1        30,000             12,000 (=30,000 * .4)            18,000

            2        18,000             7,200 (=18,000 * .4)             10,800

            3        10,800             4,320 (=10,800 * .4)             6,480

            4        6,480             1,480 **                                  5,000

            5        --no depreciation allowed--

Note that in year 4, the calculated depreciation would have been 2592 (6,480 * .4), but only 1480 was allowed because that brought the asset value down to its salvage value level. Even though the asset is used in year 5, there is no taxable depreciation expense allowed. Note again, however, that in year 3 the calculated depreciation is actually less than the straight-line amount would be for that year (4,320 vs. 5,000); at that point, depreciation is usually switched to straight-line, so the actual schedule calculated should have been:

Year    Start Value      Depreciation                            End Value

            1        30,000             12,000 (=30,000 * .4)            18,000

            2        18,000             7,200 (=18,000 * .4)             10,800

            3        10,800             5,000                                       5,800     (5000 > [10,800 * .4])

            4        6,480                  800                                      5,000

            5        --no depreciation allowed-

Again, the salvage value is as low as the ending balance is permitted to go.

MY Current C++ coding using VS:

Asset.h

#pragma once

class Asset

{

public:

       Asset(double Cost, double Salvage, int life);

       ~Asset(void);

       double getOrigCost(), getOrigSalvage(), getAnnualDep();

       double getBegBal(int year), getEndBal(int year);

       int getOrigLife();

private:

       double ocost, osalv, anndep;

       int olife;

       double* bbal;

       double* ebal;

};

Asset.cpp

#include "stdafx.h"

#include "Asset.h"

Asset::Asset(double c, double s, int l)

{

       ocost = c;

       osalv = s;

       olife = l;

       anndep = (c - s) / l;

       //declare arrays for starting and ending values

       bbal = new double[olife];

       ebal = new double[olife];

       //calculate straight line depreciation values

       bbal[0] = ocost;

       for (int i = 0; i < olife; i++)

       {

              if (i > 0)

              {

                     bbal[i] = ebal[i - 1];

              }

              ebal[i] = bbal[i] - anndep;

       }

}

double Asset::getAnnualDep()

{

       return anndep;

}

double Asset::getOrigCost()

{

       return ocost;

}

double Asset::getOrigSalvage()

{

       return osalv;

}

int Asset::getOrigLife()

{

       return olife;

}

double Asset::getBegBal(int y)

{

       return bbal[y-1];

}

double Asset::getEndBal(int y)

{

       return ebal[y-1];

}

Asset::~Asset(void)

{

}

Depreciation.cpp

// Depreciation.cpp : main project file.

#include "stdafx.h"

#include <iostream>

#include "Asset.h"

using namespace std;

using namespace System;

int main()

{

       //normal input tasks go here - with full data validation

       Asset a = Asset(30000.00,2000.00,7);

       cout << "The annual depreciation = " << a.getAnnualDep() << endl;

       for (int i = 1; i <= a.getOrigLife(); i++)

       {

              cout << i << " " << a.getBegBal(i) << " " << a.getAnnualDep() << " " << a.getEndBal(i) << endl;

       }

       system("Pause");

    return 0;

}

PLEASE write in C++ programe code!

Explanation / Answer

Asset.cpp
-------------------------
#include "stdafx.h"
#include "Asset.h"


Asset::Asset(double cost, double salvage, int life)
{
   origCost = cost;
   origSalvage = salvage;
   origLife = life;
   annualDepreciation = ((cost - salvage) / life);
   bbal = new double[origLife];
   ebal = new double[origLife];

   bbal[0] = origCost;
   for (int i = 0; i < origLife; i++) {
       if (i > 0) {
           bbal[i] = ebal[i - 1];
       }
       ebal[i] = bbal[i] - annualDepreciation;
   }
}

double Asset::getOrigCost()
{
   return origCost;
}

double Asset::getOrigSalvage()
{
   return origSalvage;
}

double Asset::getAnnualDepreciation()
{
   return annualDepreciation;
}

double Asset::getBegBal(int year)
{
   return bbal[year-1];
}

double Asset::getEndVal(int year)
{
   return ebal[year-1];
}

int Asset::getOriginalLife()
{
   return origLife;
}

Asset::~Asset()
{
}
----------------------------------------------------------
Asset.h
-------------------------
#pragma once
class Asset
{
public:
   Asset(double, double, int);
   ~Asset(void);
  
   double getOrigCost();
   double getOrigSalvage();
   double getAnnualDepreciation();
   double getBegBal(int);
   double getEndVal(int);
   int getOriginalLife();

private:
   double origCost;
   double origSalvage;
   double annualDepreciation;
   int origLife;

   double* bbal;
   double* ebal;
};
----------------------------------------------------------
Depreciation.cpp
-------------------------
#include "stdafx.h"
#include "Asset.h"
#include <iostream>
#include <string>

using namespace std;
using namespace System;

bool choose(string);
double getValue(string);

int main()
{
   cout << "Welcome to the depreciation calcultor" << endl;

   do {
       double cost = getValue("Please enter the asset cost: ");
       double salvage = getValue("Please enter the salvage value: ");
       int life = (int)getValue("Please enter the asset life (in years): ");

       Asset a = Asset(cost, salvage, life);
      
       cout << " The annual depreciation allowance on a $" << a.getOrigCost() << " asset with a salvage value of $" << a.getOrigSalvage() << " and a life of " << a.getOriginalLife() << " years = $" << a.getAnnualDepreciation() << " per year under straight-line." << endl << endl;
       if (choose("Would you like to see a complete schedule? ")) {
           cout << "Year | Start Value | Depreciation | End Value" << endl;
           for (int i = 1; i < a.getOriginalLife() + 1; i++) {
               cout << i << " " << a.getBegBal(i) << " " << a.getAnnualDepreciation() << " " << a.getEndVal(i) << endl;
           }
       }
   } while (choose("Would you like to calculate another depreciation? "));

   cout << "Thanks for using the depreciation calculator" << endl << endl;
   system("Pause");
    return 0;
}

bool choose(string message) {
   char choice;
   cin.ignore(1000, ' ');
   cout << message;
   cin >> choice;

   if (!cin.good()) {
       cin.clear();
       cin.ignore(1000, ' ');
       return false;
   }
   else if (choice == 'y' || choice == 'Y') {
       return true;
   }

   return false;
}

double getValue(string message) {
   double value;

   do {
       cout << message;
       cin >> value;

       if (!cin.good()) {
           cin.clear();
           cin.ignore(numeric_limits<streamsize>::max(), ' ');
           cout << "Your data was bad so I could not decipher your input as a decimal value." << endl;
           value = -1;
       }
       else if (value < 1) {
           cout << "Please enter a positive value." << endl;
       }

   } while (value < 1);

   return value;
}
-------------------------------------------------
stdafx.h
-------------------------

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once