I am new to c programming. I am trying to write a parking garage program that uses arrays to find the charge for each car and the total charge. Here is what I have so far. Please help me in any way that you can.
#include <stdio.h>
#include <math.h>
float calculateCharges(float);
int NUMBER_OF_CARS = 3;
main()
{
int x = 1;
float fHours[NUMBER_OF_CARS];
float fCharge[NUMBER_OF_CARS];
for(x=1; x<=NUMBER_OF_CARS; x++)
{
printf("Enter number of hours for car %d: ", x);
scanf("%f", &fHours[x]);
}
printf("\n\n");
printf("Car\t\tHours\t\tCharge\n");
for(x=1;x<4;x++)
{
printf("%d\t\t%.1f\t\t%.2f\n", x, fHours, fCharge);
}
}
float calculateCharges(float fHours)
{
float fCharge = 0.0;
if(fHours < 3)
{
fCharge = 2.00;
return fCharge;
}
else
{
fHours = fHours-3;
fCharge = ceil(fHours) * 0.5;
fCharge = 2.00 + fCharge;
if(fCharge > 10)
{
fCharge = 10;
return fCharge;
}
else
return fCharge;
}
}