Sep 23, 2009 at 8:28am
I need a help..this is for my project....
i need to create an depreciation table using do while loop in c++.....
method to be used are:
straight line method
sum of the years digit
double declining balance...
urgent response is much appreciated...
Sep 23, 2009 at 8:43am
If you are looking for someone to give you the code, you will probably be out of luck.
How it works here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
while(!finished)
{
do
{
writeCode();
}while(!stuck);
if(stuck)
{
postCode();
AskSpecificQuestion();
GetAnswer();
}
}
HandInCourseWork();
|
Last edited on Sep 23, 2009 at 8:51am
Sep 23, 2009 at 2:01pm
# include <iostream>
# include <iomanip>
# include <cassert>
using namespace std;
void straightline (double amount, int numyears)
{
double depreciation= amount/numyears;
cout<<"\nYear - Depreciation";
cout<<"\n-------------------n";
cout<< fixed<<showpoint<<right
<< setprecision(2);
for( int year=1; year<=numyears; year++)
cout << setw(3) <<year;
cout<< setw(13)<<depreciation<<endl;
}
i cant compile!!! what is the prolem?
Sep 23, 2009 at 2:46pm
You have no main function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;
void straightline (double amount, int numyears)
{
double depreciation= amount/numyears;
cout<<"\nYear - Depreciation";
cout<<"\n-------------------n";
cout<< fixed<<showpoint<<right
<< setprecision(2);
for( int year=1; year<=numyears; year++)
cout << setw(3) <<year;
cout<< setw(13)<<depreciation<<endl;
}
int main()
{
return 0;
}
|
NB: when posting code put [co
de] above your code, and [/co
de]below it.
[co
de]
int main()
{
return 0;
}
[/co
de]
will display as
1 2 3 4
|
int main()
{
return 0;
}
|
Last edited on Sep 23, 2009 at 2:49pm
Sep 25, 2009 at 3:59pm
Last edited on Sep 25, 2009 at 4:19pm
Sep 25, 2009 at 4:15pm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
using namespace std;
int main()
{
double amount, depreciation;
int numyears,yearsum;
cout<<"Enter the Value:";
cin >>amount;
cout<<"Enter the number of useful years:";
cin>>numyears;
cout<<"\nYear-Depreciation-RealizableValue";
cout<<"\n-------------------------------\n";
yearsum=sum(numyears);
cout<<fixed<<showpoint<<right<<setprecision(2);
for (int year=1; year<=numyears; year++)
depreciation=(numyears-year*1)*amount/yearsum;
realizable=amount-depreciation;
cout<<setw(3)<<year;
cout<<setw(13)<<depreciation<<endl;
cout<<realizable<<endl;
return 0;
}
|
Last edited on Sep 25, 2009 at 4:17pm
Sep 25, 2009 at 4:16pm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
using namespace std;
int main()
{
double amount,depreciation,realizable;
int numyears;
cout<<"Enter the Value:";
cin >>amount;
cout<<"Enter the number of useful years:";
cin>>numyears;
depreciation= amount/numyears;
realizable=amount-depreciation;
cout<<"\nYear - Depreciation-Net Realizable Value";
cout<<"\n-------------------n";
cout<< fixed<<showpoint<<right;
cout<<depreciation<<endl;
for( int year=1; year<=numyears; year++);
cout<<year;
cout<<depreciation<<endl;
cout<<realizable<<endl;
return 0;
}
|
Last edited on Sep 25, 2009 at 4:17pm