Hi everyone!
/* A program that calculates and print the parking charges for each of 3 customers who parked their car in the garage yesterday
*/
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
int main()
{
float hours,
totalHour = 0,
totalCharge = 0;
float calculateCharges(float);
void head(void);
head();
for(int a = 1; a < 4; a++) {
cout << setw(9) << ":";
cin >> hours;
cout << a << setw(10) << hours << "h" << setw(8) << "$"
<< calculateCharges(hours)
<< endl << endl;
totalHour += hours;
totalCharge += charges; //[B]THIS IS WHAT I TRIED. NO GOOD[B]
//[B] I GET --UNDERFINED SYMBOL IN FUNCTION MAIN--- ERROR[B]
}
cout << "TOTAL" << setw(7) << totalHours;
return 0;
}
float calculateCharges(float h) {
float charges;
if (h <= 3) {
charges = 2;
return charges;
}
else
if (h >= 19) {
charges = 10;
return charges;
}
else
return charges = (h-3)*.50 + 2;
}
void head (void) {
cout << "Cars" << setw(9) << "Hours" << setw(12)
<< "Charges" << endl;
cout << "----" << setw(9) << "-----" << setw(12) << "-------"
<< endl;
}
I have managed to do what it has asked me to do. The only that is wrong with it is that I CAN'T GET THE TOTAL FOR THE CHARGES.
Can someone help me, what should I do?
I tried doing the same for what I did with [B]totalHours[B] but it doesn't work. I get an error message ---Underfined symbol in function main---
Pleaseeeeeeeee help Pleassseeeeeeeeeeeeee...
Many thanks in advance