Introduction You have been contracted by Adcock Forest Products to produce a bas
ID: 3695480 • Letter: I
Question
Introduction You have been contracted by Adcock Forest Products to produce a basic data input, edit, calculate volumes, and display details for a Forest Inventory System. Your C++ program should be modular (see the specified function table), contain no global variables, be clear and concise, have meaningful data names, and informative comments Brief Description of Application Forest product organizations and other forestry related firms will often statistically sample their forests to determine estimates of current and future volumes. They do this by selecting a large number ofrelatively small plots of perhaps 1/10th of an acre. They then will measure all trees on each plot that are beyond a given size. In this particular example we have used minimum sizes of 5.0 inches for dbh (diameter at breast height) and 22 feet for total height. Ordinarily one would include plot measurements as well as the individual tree data. I have attempted to keep this simple and we are only measuring the trees on a single plot and ignoring plot data. The regression coefficients are values that I have made up so don't try to interpret any hidden meanings into the results Overview of Program Lo gic You are to have a major while control loop that allows the user to enter data tree by tree until a tree number of 999 is encountered Program is to be modular and utilize blocks of code that include getTreeNo etSpciesDbh, getTotHt, calcTotVol and displayTreeData fnctions Absolutely no global variables are to be used. Each get function has its own cin command that inputs the respective variable Edit the incoming data according to the stated specifications for legal data values You are to use a do/while loop for data entry and keep the user in the loop until valid data is entered for the tree Total volume for each individual tree is calculated using the totalVol formula Write the respective tree data (treeNo, speciesCode, dbh, totalHt, and totalVol.) for each entry once the entire record is validated. This output is to be stored on an extermal data file named report.dat as well as the standard output (cout) device Once a tree number of999 is entered, the program should exit the while loop and then calculate and display (1) the total number of trees entered, and (2) the average total volume. (Note: the average totalVol is determined by the sum of totalVol values divided by the total number of trees.) The above output is to be displayed on report.dat as well as the standard cout device 1. 2. 3. 4. 5. 6.Explanation / Answer
using namespace std;
//declaring function prototypes
int getTreeNo(int);
int getSpeciesCode(int);
float getDbh(float);
int getTotHt(int);
int getTotHt(int);
double calcTotVol(double[], double[], float, int);
int main()
{
//declaring and initializing variables
int i = 0;
int treeNo = 0;
int speciesCode = 0;
string speciesDesc[6] = {};
float dbh = 0.00;
int totalHt = 0;
double totalVol = 0.00;
int Species[6] = {};
double b0[6] = {};
double b1[6] = {};
int noTrees = 0;
treeNo = getTreeNo(treeNo);
//Gets number of trees for calculation
speciesCode = getSpeciesCode(speciesCode);
// Get Species code from user
dbh = getDbh(dbh);
//get DBH from user
totalHt = getTotHt(totalHt);
totalVol = calcTotVol(b0, b1, dbh, totalHt);
if (speciesCode = 11)
{
speciesDesc[0] = "Loblolly Pine";
}
else if (speciesCode = 12)
{
speciesDesc[1] = "White Pine";
}
else if (speciesCode = 13)
{
speciesDesc[2] = "Red Pine";
}
else if (speciesCode = 21) {
speciesDesc[3] = "White Oak";
}
else if (speciesCode = 22)
{
speciesDesc[4] = "Red Oak";
}
else if (speciesCode = 23)
{
speciesDesc[5] = "Other Oak";
}
Species[0] = 11;
Species[1] = 12;
Species[2] = 13;
Species[3] = 21;
Species[4] = 22;
Species[5] = 23;
if (speciesCode = 11) {
b0[0] = 1.2446;
}
else if (speciesCode = 12) {
b0[1] = 0.000;
}
else if (speciesCode = 13)
{
b0[2] = 2.0822;
}
else if (speciesCode = 21)
{
b0[3] = .7316;
} else if (speciesCode = 22)
{
b0[4] = 1.6378;
} else if (speciesCode = 23) {
b0[5] = .7554;
}
if (speciesCode = 11)
{
b1[0] = .002165;
}
else if (speciesCode = 12)
{
b1[1] = .002364;
}
else if (speciesCode = 13) {
b1[2] = .002046;
}
else if (speciesCode = 21)
{
b1[3] = .001951;
}
else if (speciesCode = 22)
{
b1[4] = .002032;
}
else if (speciesCode = 23)
{
b1[5] = .002174;
}
totalVol = b0[6] + b1[6] * pow(dbh, 2) * totalHt;
for (i = 0; i < treeNo; i++) {
cout << "Tree Number " << i + 1 << ": " << speciesCode << dbh << totalHt
<< speciesDesc[6] << b0[6] << b1[6] << totalVol;
}
}
int getTreeNo(int treeNo)
{
do {
cout << "Please enter the number of trees :" << endl;
cin >> treeNo;
if ((treeNo <= 0) || (treeNo > 999)) {
cout << "ERROR!!!,You cannot have more then999 entries" << endl;
}
} while ((treeNo <= 0) || (treeNo > 999));
return treeNo;
}
int getSpeciesCode(int speciesCode) {
do {
cout << "Please enter your Species Code";
cin >> speciesCode;
} while ((speciesCode != 11) &&(speciesCode != 12) &&
(speciesCode != 13)&& (speciesCode != 21) &&
(speciesCode != 22) && (speciesCode != 23));
cout << "ERROR!!!,That information does not exist wthin our system" << endl;
return speciesCode;
}
float getDbh(float dbh)
{
do {
cout << "Please enter the DBH of the tree, The DBH must be greter then "
"and equal to five and less then 50.6" << endl;
cin >> dbh;
if ((dbh < 5) && (dbh > 50.6)) {
cout << "ERROR!!!, The DBH must be greter then and equal to five "
"and less then 50.6" << endl;
}
} while ((dbh < 5) &&(dbh > 50.6));
return dbh;
}
int getTotHt(int totalHt) {
do {
cout << "Please enter the height of the tree" << endl;
cin >> totalHt;
if ((totalHt < 24) && (totalHt > 160)) {
cout << "ERROR!!!, Please enter a height thats not larger then "
"160, but greater then 24" << endl;
}
} while (totalHt < 24 && totalHt > 160);
{ return totalHt; }
}
double calcTotVol(double array[], double array1[], float dbh, int totalHt)
{
double totalVol;
totalVol = array[6] + array1[6] * pow(dbh, 2) * totalHt;
return totalVol;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.