This is the program
A parking garage charges $2 for minimum fee to park up to 3 hours and then a $.50 per hour charge after the 3rd hour. write a program that calculates and prints the parking charge for each of # customer. Result should be printed in tabular format. the program should use the function calculateCharges to determine the charge for each customer.
here is my code but i get some compile errors and i do not see where there is a mistake
Code:
#include <stdio.h>
double calculateCharges (double hours, double charge);
int main()
{
int cars;
double totalHours = 0;
double totalCharge = 0;
printf ("Please enter the number of cars parked for the day:\n");
scanf ("%d", &cars);
if (cars >= 1){
printf ("Car\tHours\tCharge\n");
printf ("%d\t%.1f\t%.2f\n", cars, calculateCharges(hours, charge));
totalHours = totalHours + hours;
totalCharge = totalCharge + charge;
cars--;
}
if (cars == 0){
printf ("Total\t%.1f\t%.2f\n", totalHours, totalCharge);
}
return (0);
}
double calculateCharges (double hours, double charge)
{
double minRate = 2.00;
double rate = 0.50;
printf ("please enter cars total hours:");
scanf ("%.2f", &hours);
if (hours < 3) {
charge = minRate;
}
else {
charge = minRate + (rate * (hours -3));
}
return;
}
here is my compiler errors
Code:
-------------------Configuration: parking - Win32 Debug--------------------
Compiling...
parking.c
C:\C Files\Chapter_5\parking\parking.c(19) : error C2065: 'hours' : undeclared identifier
C:\C Files\Chapter_5\parking\parking.c(19) : error C2065: 'charge' : undeclared identifier
C:\C Files\Chapter_5\parking\parking.c(52) : warning C4033: 'calculateCharges' must return a value
Error executing cl.exe.
parking.obj - 2 error(s), 1 warning(s)
thanks,
joe