C program to calculate parking garage charges based of the hours parked.

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a neat tabular format, and should calculate and print the total of yesterday’s receipts. The program should use the function calculate charges to determine the charge for each customer. Your outputs should appear in the following format:

Car     Hours     Total

1         1.5            2.00

2         4.0           2.50

3        24.0         10.00

Total  2.00         14.50

#include <stdio.h>

float charge(float x){
if (x > 0 && x <= 3.0){
return2.0;
}
elseif (x > 3.0 && x < 24.0){
return2.0 + ((x-3)*0.5);
}
elseif (x == 24.0) {
return10.0;
}
}

int main()
{
int carnum;
float totalcharge = 0;
float totalhour = 0;
printf(“Enter the number of the vehicles: “);
scanf(“%d”, &carnum);
floathour[carnum];
for (int i = 0; i < carnum; i++){
printf(“Enter the parking hours of car %d : “, i+1);
scanf(“%f”, &hour[i]);
totalhour += hour[i];
}
printf(“Car\t\tHour\t\tTotal Charge\n”);
for (int i = 0; i < carnum; i++){
printf(“%d\t\t%.1f\t\t%.2f\n”, i+1, hour[i], charge(hour[i]));
totalcharge += charge(hour[i]);
}
printf(“Total\t\t%.1f\t\t%.2f\n”, totalhour, totalcharge);
return 0;
}
P