Question: I'm doing a C++ program for class and my professor told me that I had to use Referance parameters and void return function for my

I'm doing a C++ program for class and my professor told me that I had to use Referance parameters and void return function for my calculations and I'm not too sure how to do that.

#include

#include

#include

using namespace std;

double interiorCost(double area, double cost);

double totalAmount(double total);

double exteriorCost(double area, double cost);

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

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

//calculate the interior Cost

//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;

}

//calculate the total

double total = (interiorCost(intArea, intCost) + exteriorCost(extArea, extCost));

double discount = 0;

//output to out file

oFile<

oFile<

oFile<

oFile<

oFile<

//calculate the discount

if (total > 1000)

{

discount=total*0.1;

}

// Discount and final price

oFile<

oFile<

}

//close the files

inFile.close();

oFile.close();

eFile.close();

return 0;

}//Calculate interiorcost

double interiorCost(double area, double cost)

{

return area*cost;

}

//calculate the exterior Cost

double exteriorCost(double area, double cost)

{

return area*cost;

}

//calculate the total after the discount

double totalAmount(double total)

{

// Apply discount if price is greater than $1000

if(total >1000)

{

double totalAmount=total*0.1;

return total-totalAmount;

}

return total;

}

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;

}

double interiorCost(double area, double cost) { return area*cost; } //calculate the exterior Cost double exteriorCost(double area, double cost) { return area*cost; } //calculate the total after the discount double totalAmount(double total) { // Apply discount if price is greater than $1000 if(total >1000) { double totalAmount=total*0.1; return total-totalAmount; } return total;

I need to combine those three functions into one void returning 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!