How can I make the void functions into a value returning functions

I have this code and it works and has passed all tests. However I need them with a value returning function and not a void function. I'm having a very difficult time figuring it out. Any help would be much appreciated. Thank you in advance.

#include <iomanip>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

const double dmeal = 25.80;
const double smeal = 21.75;
const double tax = 0.18;
const double sur = 0.07;

void ReadData(int &NumAdults, int &NumKids, char &MealType, char &Weekend, double &Deposit, bool &ANumError, bool &KNumError, bool &MealError, bool &WeekendError, bool &DepositError);

void CalcSubTotal(int NumAdults, int NumKids, char MealType, double &SubTotal, double &TaxTip, double &Acost, double &Kcost, double &Total, double tax, double smeal, double dmeal);

void CalcSurcharge(char Weekend, double TaxTip, double &Surcharge, double Total, double &Balance, double Deposit, double sur, double &PostTotal);

void Calcdiscount(double &PostTotal, double &Discount);

void Output(int NumAdults, int NumKids, double Acost, double Kcost, double SubTotal, double TaxTip, double Surcharge, double PostTotal, double Deposit, double Balance, double Discount);

ifstream infile;
ofstream outfile;
ofstream errorfile;

int main()

{

int NumAdults, NumKids;
double Acost, Kcost, SubTotal, Deposit, TaxTip, Surcharge, Total, Discount, Balance, PostTotal;
char MealType, Weekend;
bool ANumError = 0, KNumError = 0, MealError = 0, WeekendError = 0, DepositError = 0;

Acost = 0; Kcost = 0; SubTotal = 0; Deposit = 0; TaxTip = 0; Surcharge = 0; Total = 0; Discount = 0; Balance = 0; PostTotal = 0;


infile.open("file address infile");
if (!infile) //!cin
{
cout << "File not fount. Program terminating!" << endl;
system("pause"); //program termination point
exit(1);
}


outfile.open("OutFile.txt");
errorfile.open("ErrorFile.txt");

while (!infile.eof())
{
ReadData(NumAdults, NumKids, MealType, Weekend, Deposit, ANumError, KNumError, MealError, WeekendError, DepositError);

if ((ANumError == 0) && (KNumError == 0) && (MealError == 0) && (WeekendError == 0) && (DepositError == 0))
{
CalcSubTotal(NumAdults, NumKids, MealType, SubTotal, TaxTip, Acost, Kcost, Total, tax, smeal, dmeal);
CalcSurcharge(Weekend, TaxTip, Surcharge, Total, Balance, Deposit, sur, PostTotal);
Calcdiscount(PostTotal, Discount);
Output(NumAdults, NumKids, Acost, Kcost, SubTotal, TaxTip, Surcharge, PostTotal, Deposit, Balance, Discount);
}


}


infile.close();
outfile.close();
errorfile.close();
return 0;

}

void ReadData(int &NumAdults, int &NumKids, char &MealType, char &Weekend, double &Deposit, bool &ANumError, bool &KNumError, bool &MealError, bool &WeekendError, bool &DepositError)
{
infile >> NumAdults >> NumKids >> MealType >> Weekend >> Deposit;

if (NumAdults < 0)
{
errorfile << "Number of Adults can't be negative." << endl << NumAdults << " " << NumKids << " " << MealType << " " << Weekend << " " << Deposit << endl;
ANumError = 1;
}
if (NumKids < 0)
{
errorfile << "Number of children can't be negative" << endl << NumAdults << " " << NumKids << " " << MealType << " " << Weekend << " " << Deposit << endl;
KNumError = 1;
}
if ((MealType != 'S') && (MealType != 'D'))
{
errorfile << "Invalid character for meal type" << endl << NumAdults << " " << NumKids << " " << MealType << " " << Weekend << " " << Deposit << endl;
MealError = 1;
}
if ((Weekend != 'N') && (Weekend != 'Y'))
{
errorfile << "Invalid character for weekend" << endl << NumAdults << " " << NumKids << " " << MealType << " " << Weekend << " " << Deposit << endl;
WeekendError = 1;
}
if (Deposit < 0)
{
errorfile << "Deposit can't be negative" << endl << NumAdults << " " << NumKids << " " << MealType << " " << Weekend << " " << Deposit << endl;
DepositError = 1;
}
}

void CalcSubTotal(int NumAdults, int NumKids, char MealType, double &SubTotal, double &TaxTip, double &Acost, double &Kcost, double &Total, double tax, double smeal, double dmeal)
{
if (MealType == 'S')
{
Acost = smeal * NumAdults;
Kcost = (smeal * 0.60) * NumKids;

}
if (MealType == 'D')
{
Acost = dmeal * NumAdults;
Kcost = (dmeal * 0.60) * NumKids;

}
SubTotal = Acost + Kcost;
TaxTip = SubTotal * tax;
Total = SubTotal + TaxTip;
}

void CalcSurcharge(char Weekend, double TaxTip, double &Surcharge, double Total, double &Balance, double Deposit, double sur, double &PostTotal)
{
if (Weekend == 'Y')
{
Surcharge = Total * sur;
PostTotal = Total + Surcharge;
}
else
{
Surcharge = 0;
PostTotal = Total + Surcharge; //to calculate the surcharge
}
Balance = PostTotal - Deposit;
}

void Calcdiscount(double &PostTotal, double &Discount)
{
if (PostTotal >= 400.00)
{
Discount = PostTotal * 0.035;
}
else if ((PostTotal < 400.00) && (PostTotal >= 100.00))
{
Discount = PostTotal * 0.025;
}
else if (PostTotal < 100.00)
{
Discount = PostTotal * 0.015; //to calculate the discount
}
}



void Output(int NumAdults, int NumKids, double Acost, double Kcost, double SubTotal, double TaxTip, double Surcharge, double PostTotal, double Deposit, double Balance, double Discount)
{
outfile << fixed << showpoint << setprecision(2) << setw(10);
outfile << "Number of Adults: \t" << setw(10) << NumAdults << endl;
outfile << "Number of Children: \t" << setw(10) << NumKids << endl;
outfile << "Cost of Adult Meal: \t" << setw(10) << Acost << endl;
outfile << "Cost of Child Meal: \t" << setw(10) << Kcost << endl;
outfile << "Total Food Charge: \t" << setw(10) << SubTotal << endl;
outfile << "Tax and Tip: \t\t" << setw(10) << TaxTip << endl;
outfile << "Surcharge: \t\t" << setw(10) << Surcharge << endl;
outfile << "Total Party Cost: \t" << setw(10) << PostTotal << endl;
outfile << "Deposit: \t\t" << setw(10) << Deposit << endl;
outfile << "Total Balance Due: \t" << setw(10) << Balance << endl;
outfile << "Discount: \t\t" << setw(10) << Discount << endl
<< "Get these savings by paying the bill within 10 days." << endl << "Don't miss out on this chance to save." << endl << endl;
}
Take a quick look at this tutorial:

http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.