:rolleyes: Hi. I'm new to this forum and well I'm also new to the programming languages. :) and im taking some programming classes c++) i need help with a program that im working on... I have tried for about two days to see what is the problem but i just dont get it. May be some one over can help me. Thanks
/* straightlinedepr.cpp */
#include <iostream> // student ...... xXXXX
#include <cmath> // assignment ... straight line depreciation
#include <cstdlib> // due date .....10/13/2005
#include <iomanip> //
using namespace std; // name-conflict avoidance
void SetPrecision(int); // procdedure prototype
int main (void) // main function header
{
/* local data space */
double cost, scrap; // declare input values
int years; //
double CalcDepr ( double, double, int);
double yrlyDepr,cumDepr,bookVal; // declare derived
int year; // loop control var
/* begin procedural code */
SetPrecision(2); // set float precision
/* get input values */
cout<< "Enter the cost: "; //prompt
cin>> cost;
cout<< "Enter scrap value: "; //prompt
cin>> scrap;
cout<< "Enter lfe in years: ";
cin>> years;
/* display column headers */
cout << setw(6) << "Year"
<< setw(13) << "Yearly Depr"
<< setw(10) << "Cum Depr"
<< setw(12) << "Book Value" << "\n\n";
/* pre-loop value calculations */
yrlyDepr = CalcDepr(cost, scrap, years); // call function
double CalcDepr( double p_cost, double p_scrap, int p_years);
{
double depr;
depr= (p_cost - p_scrap)/ (float) p_years;
return(depr);
}
cumDepr= 0;
bookVal= cost;
for ( year=1; year<=8;year++)
{
cumDepr=cumDepr +yrlyDepr;
bookVal= bookVal-yrlyDepr;
/*display detail line */
cout<< setw(6)<<year<<setw (13)<< yrlyDepr<< setw(10)<<cumDepr<< setw(12
)<<bookVal<< endl;
}
/* develop repetiiton schedule */
return(0); // int return to o/s
}
void SetPrecision(int p_decPlaces) // procedure header
{ // begin block
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.setf(ios::right);
cout.precision(p_decPlaces);
return; // return to caller
} // end block
-bash-3.00$ aCC -AA straightlinedepr.cpp -o straightlinedepr
Error 172: "straightlinedepr.cpp", line 48 # Undeclared variable 'p_cost'.
depr= (p_cost - p_scrap)/ (float) p_years;
^^^^^^
-bash-3.00$