Question: I am having trouble with my code. My void function for my output data is not working. #include #include #include using namespace std; //Prototypes void

I am having trouble with my code. My void function for my output data is not working.

#include

#include

#include

using namespace std;

//Prototypes

void output(ofstream oFile, int name, int ID, int interiorCost, int exteriorCost, int total);

void calculation(double &intArea, double &intCost, double &extArea, double &extCost, double &interiorCost, double &exteriorCost, double &discount, double &total, double &totalAmount);

//to check whether the input value is positive or not

bool checkInput(int number, double num1, double num2, double num3, double num4);

//main funcation

int main()

{

string name;

int ID;

double intArea=0, extArea=0;

double intCost=0, extCost=0;

ifstream inFile;

ofstream oFile;

ofstream eFile;

//declarartion for input, output, error files.

string fileName, outfile="output.txt", errorfile="error.txt";

//open the file name

inFile.open("Lab6DATA.txt");

//throw error if file opening has error

if (!inFile)

{

cout << "Error opening file ";

exit(1);

}

oFile.open (outfile);

//error if file opening has error

if (!oFile)

{

cout << "Error opening output file ";

inFile.close();

exit(1);

}

eFile.open (errorfile);

//error if file opening has error

if (!eFile)

{

cout << "Error opening error file ";

inFile.close();

oFile.close();

exit(1);

}

oFile << fixed;

eFile << "Invlaid data entered ";

//Read inputfile

while (inFile >> name >> ID >> intArea >> intCost >> extArea >> extCost)

{

if (checkInput(ID, intArea, intCost, extArea, extCost) == false)

{

eFile << name <<"\t"<

continue;

}

double discount = 0;

double interiorCost = 0;

double exteriorCost = 0;

double total = 0;

double totalAmount = 0;

//calculate the total

calculation(intArea, intCost, extArea, extCost, interiorCost, exteriorCost, discount, total, totalAmount);

//output to out file

// Discount and final price

output(oFile, name, ID, interiorCost, exteriorCost, total);

//Problem code ^ won't call the void funtion

}

//close the files

inFile.close();

oFile.close();

eFile.close();

return 0;

}

//Calculations

void calculation(double &intArea, double &intCost, double &extArea, double &extCost, double &interiorCost, double &exteriorCost, double &discount, double &total, double &totalAmount){

//Calculate interiorcost

interiorCost = intArea * intCost;

//calculate the exterior Cost

exteriorCost = extArea * extCost;

//calculate the total

total = interiorCost + exteriorCost;

//calculate the discount

if (total > 1000)

{

discount = total *0.1;

}

//calculate the total after the discount

totalAmount = total - discount;

}

//Checking for negatives

bool checkInput(int number, double num1, double num2, double num3, double num4)

{

if (num1 < 0 || num2 < 0 || num3 < 0 || num4 < 0 || number <= 0)

{

return false;

}

return true;

}

void output(ofstream oFile, int name, int ID, double interiorCost, double exteriorCost, double discount, double total, double totalAmount)

{

oFile<

oFile<

oFile<

oFile<

oFile<

oFile<

oFile<

}

//This function is supposed to output to the data file ^ But it isn't linking with the call function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!