for some reason i cant call my subfunctions
i am reading from a cater.data file
and printing to a bill.out
any help the error statement i am given when trying to compile lets me know it is trying to read my called functions as a variable
i.e.
error heading not defined in this scope
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
ifstream cater;
ofstream bill;
int adultnum,
count,
kidnum;
double avgbill,
dsert,
dpt,
grat,
mcorsa,
mcorsk,
rmfee,
sumcorsa,
sumcorsk,
sumdsert,
sumcors,
txntip,
tax,
total,
totalbill;
cater.open("cater.data");
bill.open("bill.out");
void stars(ofstream);
void underscore(ofstream);
totalbill=0.00;
count=0;
cater >> kidnum, adultnum, mcorsa, dsert, rmfee, grat, tax, dpt;
while (cater)
{
heading(bill.out);
txntip = calctax(tax,sumcors,grat);
mcorsk = kidsmeal(kidnum,mcorsa);
sumcorsa = mcorsa * adultnum;
sumcorsk = mcorsk * kidnum;
sumdsert = dsert*(kidnum + adultnum);
sumcors = foods(sumcorsa, sumcorsk, sumdsert);
total – calctotal(rmfee,dpt);
bill << left << " Number of adults: \n " << setw(4) << adultnum;
bill << left << " Number of children: \n " << setw(4) << kidnum;
bill << left << " Cost per adult without dessert: \n$" << setw(6) << mcorsa;
bill << left << " Cost per child without dessert: \n$" << setw(6) << mcorsk;
bill << left << " Cost per dessert: \n$" << setw(6) << dsert;
bill << left << " Room Fee: \n$" << setw(6) << rmfee;
bill << left << " Tip rate: \n$" << setw(6) << grat;
bill << left << " Tax rate: \n$" << setw(6) << tax;
underscore(bill);
bill << left << " Total cost for adult meals: \n$" << setw(6) << sumcorsa;
bill << left << " Total cost for child meals: \n$" << setw(6) << sumcorsk;
bill << left << " Total cost for dessert: \n$" << setw(6) << sumdsert;
underscore(bill);
bill << left << " Total food cost: \n$" << setw(6) << sumcors;
bill << left << " Tax and tip: \n$" << setw(6) << txntip;
bill << left << " Room Fee: \n$" << setw(6) << rmfee;
bill << left << " LESS DEPOSIT: \n$" << setw(6) << dpt;
underscore(bill);
bill << left << " balance due: \n$" << setw(6) << total;
stars(bill);
bill << left << "\n";
bill << left << "\n";
totalbill = totalbill + total;
count = count++;
}
avgbill= totalbill/count;
cater.close();
bill.close();
}
void stars(ofstream &bill)
{
bill << "****************************************************\n";
}
void underscore(ofstream &bill)
{
bill << "—————————————————-\n";
}
void heading(ofstream &bill)
{
stars(bill);
bill << " Rouge catering and convention service \n ";
bill << " Final Bill \n ";
underscore(bill);
}
double kidsmeal(double &mcorsa)
{
double kidsmeal;
kidsmeal = .60 * mcorsa;
}
double calctax(double &tax, double &grat, double sumcors)
{
double totaltxtp;
totaltxtp = ((tax*sumcors) + sumcors)*grat +(tax * sumcors);
}
double foods( double sumcorsa, double sumcorsk, double sumdsert)
{
double food;
food = sumcorsa + sumcorsk + sumdsert;
}
double calctotal(double &rmfee, double &dpt, double txntip, double sumcors)
{
double final;
final = sumcors + txntip + rmfee -dpt;
}
Hm….
Yesss, C++!
C++ can define prototype function inside the body of function, even in main or child function.
But, u forgotten define heading() prototype.
And of cors, function should return a value.
Does iomanip have "left" manipulator?
November 17th, 2009 at 9:40 am
One thing I notice is this code:
void stars(ofstream);
void underscore(ofstream);
These should probably be outside all functions. In fact, the later use of underscore() is probably blowing up because it doesn’t see the above code (it’s only visible inside the main function).
Hope that helps.
References :
November 17th, 2009 at 10:01 am
Hm….
Yesss, C++!
C++ can define prototype function inside the body of function, even in main or child function.
But, u forgotten define heading() prototype.
And of cors, function should return a value.
Does iomanip have "left" manipulator?
References :