well...this is the program that i had.....
/* Calculate the total charges and the total hours for the
parking garage. */
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void calculatecharges (double hoursa, double hoursb, double hoursc);
int main()
{
double a, b, c;
cout<<"Enter the number of hours for CAR 1:";
cin>>a;
cout<<"Enter the number of hours for CAR 2:";
cin>>b;
cout<<"Enter the number of hours for CAR 3:";
cin>>c;
calculatecharges(a, b, c);
return 0;
}
void calculatecharges(double hoursa, double hoursb, double hoursc)
{
double costa = 0;
double costb = 0;
double costc = 0;
double totalhours = 0;
double totalcost = 0;
if(hoursa <= 3)
costa = 2;
else if (hoursa >= 17)
costa = 10;
else
costa = 2 + ((hoursa-3) * .5);
if(hoursb <= 3)
costb = 2;
else if (hoursb >= 17)
costb = 10;
else
costb = 2 + ((hoursa-3) * .5);
if(hoursc <= 3)
costc = 2;
else if (hoursc >= 17)
costc = 10;
else
costc = 2 + ((hoursc-3) * .5);
totalhours = hoursa + hoursb + hoursc;
totalcost = costa + costb + costc;
cout<<"CAR 1 CHARGES: "<<costa<<endl;
cout<<"CAR 2 CHARGES: "<<costb<<endl;
cout<<"CAR 3 CHARGES: "<<costc<<endl;
cout<<"TOTAL: "<<totalhours<< " hours, $"<<totalcost<<endl;
}
and now i'm told that i have to do the same program, but use 3 functions; one to calculate the charges, one to calculate the total hours, and one to calculate the total charges. this time though, i can't use global variables. my question is...what's the difference? doesn't my program fit to the new criteria? also...i still have an error with that function...why? i don't know. it just won't compile without returning an error.