Question: Please HELP with depreciation calculator 'int main' coding using C++!!! COUT in BOLD _ My coding is below the instructions, I need help with 'int
Please HELP with depreciation calculator 'int main' coding using C++!!!
COUT in BOLD _ My coding is below the instructions, I need help with 'int main' in Depreciation.cpp
Below is what I would like the calculator to do:
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). The above example would look like this:
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-years 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 Code using C++ in VB
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
#include "Asset.h"
#include
using namespace std;
using namespace System;
int choice;
bool choose(string);
bool quit;
double getVal(string);
int main()
{
char choice;
cout << "Welcome to the depreciation calculator! " << endl;
do
{
cout << " Please enter the Asset Cost (0 to quit): " << endl;
cin >> choice;
if (!cin.good())
{
cin.clear();
cin.ignore(1000, ' ');
choice = '?';
} while (choice != 0);
cout << "Thanks for using the depreciation calculator!" << endl << endl;
system("Pause");
return 0;
double cost = getVal(" ");
double salvage = getVal(" ");
Asset a = Asset(30000.00, 5000.00, 5);
cout << " The annual depreciation allowance on a " << a.getOrigCost() << "asset with a salvage value of " << a.getOrigSalvage() << " and a life of" << a.getOrigLife() << " y = " << a.getAnnualDep() << "n\per year under straight-line." << endl << endl;
if (choose( "Would you like to see a complete schedule for Straight-Line, DDL, or Neither? (S/D/N)? "))
{
cout << "Year | Start Value | Depreciaton | End Value" << endl;
for (int i = 1; i < a.getOrigLife() + 1; i++)
{
cout << i << "\t" << a.getBegBal(i) << "\t\t" << a.getAnnualDep() << "\t\t" << a.getEndBal(i) << endl;
}
}
} while (choose("Please enter the Asset Cost (0 to quit: "));
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 getVal(string message)
{
double value;
do
{
cout << message;
cin >> value;
if (!cin.good())
{
cin.clear();
cin.ignore(numeric_limits
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;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
