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

I have a program here that I thought I had worked all of the bugs out of, but I

ID: 3659978 • Letter: I

Question

I have a program here that I thought I had worked all of the bugs out of, but I am now getting an error. Could someone please help me solve what this error is. Thank You! Here is the error given and the program.

1>C:Program Files (x86)MSBuildMicrosoft.Cpp 4.0Microsoft.CppCommon.targets(562,5): error MSB6006: "mt.exe" exited with code -1073741818.

#include

<iostream>

#include

<fstream>

#include

<iomanip>

using

namespace std;

//prototype

int

getTreeNo();

int

getSpeciesCode(int[],string[]);

double

getDbh();

int

getTotHt();

double

calcTotVol(int,int[],double[],double[],double, int);

void

displayTreeData(ofstream&,int ,int ,int [], string [],double,int,double);

int

main(){

int

treeNo,speciesCode,totalHt,noTrees;

double

dbh;

double

totalVol,avgTotVol;

int

Species[6]={11,12,13,21,22,23};

string speciesDesc[6]={

"Loblolly Pine","White Pine","Red Pine","White Oak","Red Oak","Other Oak"};

double

b0[6]={1.2446,0.000,2.0822,.7316,1.6378,.7554};

double

b1[6]={.002165,.002364,.002046,.001951,.002032,.002174};

noTrees=0;

//set number of trees to 0

avgTotVol=0.0;

//set volume to 0

ofstream out(

"report.dat");//make a file out stream

out<<

"Forest Inventory Detail Edit and Volume Calculation "

<<

"Tree No. Species Description DBH Tot. Ht. Tot. Vol.";

cout<<setiosflags(ios::fixed)<<setprecision(3);

out<<setiosflags(ios::fixed)<<setprecision(3);

do

{

treeNo=getTreeNo();

if

(treeNo!=999){

speciesCode=getSpeciesCode(Species,speciesDesc);

dbh=getDbh();

totalHt=getTotHt();

totalVol=calcTotVol(speciesCode,Species,b0,b1, dbh, totalHt);

?

noTrees++;

//increment tree count

avgTotVol+=totalVol;

//add current tree's totalVol to avgTotVol

displayTreeData(out,speciesCode,treeNo,Species,speciesDesc,dbh,totalHt,totalVol);

}

}

while(treeNo!=999);

?

cout<<

" Total trees measured = "<<noTrees

<<

" Average total volume = ";

out<<

" Total trees measured = "<<noTrees

<<

" Average total volume = ";

if

(noTrees<=0){//if negative(which is impossible) or 0

cout<<0;

out<<0;

}

else

{

cout<<avgTotVol/noTrees;

out<<avgTotVol/noTrees;

}

cout<<

" Notes on Volume Determination Individual tree volumes are measured with different units. The formulas in this exercise are in cubic feet. Other common measurements are cords and cubic meters. Pulp wood is normally purchased by weight and saw logs by boardfeet. All of these can be converted from cubic feet. This exercise has taken several liberties as the real world is much more complicated than this.";

out<<

" Notes on Volume Determination Individual tree volumes are measured with different units. The formulas in this exercise are in cubic feet. Other common measurements are cords and cubic meters. Pulp wood is normally purchased by weight and saw logs by boardfeet. All of these can be converted from cubic feet. This exercise has taken several liberties as the real world is much more complicated than this.";

?

system(

"Pause");

return

0;

}

/*

getTreeNo

Input tree number, input must be type int and > 0 and less than 200 or = 999.

A value of 999 terminates input. Input is to be a do/while loop.

Function is return by value.

*/

int

getTreeNo(){

int

input;

do

{

cout<<

"Enter tree number(between 1-199) or 999 to finish: ";

cin>>input;

if

((input<1||input>199)&&input!=999){

cout<<

"Invalid number entered. ";

}

}

while((input<1||input>199)&&input!=999);

?

return

input;

}

/*

getSpeciesCode

Species code is type int and must be valid and found in the species table.

Input is a do/while loop. Function is return by value.

*/

int

getSpeciesCode(int Table[],string Name[]){

int

code;

int

found=0; //initialized to 0

do

{

//diplay Code & description

cout<<

" Code Description ";

for

(int i=0;i<6;i++){

cout<<Table[i]<<

" "<<Name<<endl;

}

//ask for input

cout<<

" Enter Species Code: ";

cin>>code;

//search Table to see if valid code entered

for

(int j=0;j<6;j++){

if

(code==Table[j]){//if found,

found =1;

//set found to 1

break

; //exit for loop

}

}

if

(found!=1){

cout<<

"Invalid code entered entered. ";

}

}

while(found!=1);

return

code;

}

/*

getDbh

Values are type double and must be greater than or equal to 5.0 and no greater than 50.6

inches. Is a return by value function.

*/

double

getDbh(){

double

inches;

do

{

cout<<

"Enter the number of inches(between 5 and 50.6): ";

cin>>inches;

if

(inches<5||inches>50.6){

cout<<

"Invalid number entered. ";

}

}

while(inches<5||inches>50.6);

return

inches;

}

/*

getTotHt

Values are type int and can range from 24 to 160.

Total height is always measured as the closest even integer.

For example, 131 would not be a valid measurement whereas 132 would be.

A return by value function.

*/

int

getTotHt(){

int

Ht;

do

{

cout<<

"Enter the closest even total height(between 24-160): ";

cin>>Ht;

if

((Ht<1||Ht>199)&&Ht%2!=0){

cout<<

"Invalid number entered Note that it must be a even number. ";

}

}

while((Ht<1||Ht>199)&&Ht%2!=0);

return

Ht;

}

/*

calcTotVol

Calculate total volume (type double)

totalVol = b0 + b1 (dbh)^2 ( totalHt)

Output is 3 decimal places to the right of the decimal.

Return by value function.

*/

double

calcTotVol(int code,int table[],double b0[],double b1[],double dbh, int totalHt){

int

index;

double

totalVol;

//find index

for

(int i=0;i<6;i++){

if

(code==table[i]){

index=i;

break

;

}

}

//calculate totalVol = b0 + b1 (dbh)^2 ( totalHt)

totalVol=b0[index]+b1[index]*dbh*dbh*totalHt;

return

totalVol;

}

/*

*/

void

displayTreeData(ofstream& out,int speciesCode,int treeNo,int table[], string Name[],double dbh,int totalHt,double totalVol){

int

index;

//find index

for

(int i=0;i<6;i++){

if

(speciesCode==table[i]){

index=i;

break

;

}

}

cout<<

" Tree No. Species Description DBH Tot. Ht. Tot. Vol.";

cout<<endl<<treeNo<<

" "<<Name<<" "<<setprecision(1)<<dbh<<" "<<totalHt<<" "<<setprecision(3)<<totalVol<<endl;

out<<endl<<treeNo<<

" "<<Name<<" "<<setprecision(1)<<dbh<<" "<<totalHt<<" "<<setprecision(3)<<totalVol;

?

system(

"Pause");

return

;

}

?

Explanation / Answer

you are still missing the string library. add the header #include