Code:
#include <stdio.h>
#include <math.h>
float calculateCharges(float hours);
//const int NUMBER_OF_CARS= 8;
#define NUMBER_OF_CARS 8
int main(void)
{
int cars[NUMBER_OF_CARS]= {1,2,3,4,5,6,7,8};
float charges[NUMBER_OF_CARS];
float hours[NUMBER_OF_CARS];
float totalHours= 0.0;
float totalCharges= 0.0;
int i;
for(i=0; i<NUMBER_OF_CARS; i++)
{
printf("Enter the hours for car %d:",i+1); //, cars[i]);
scanf("%f",&hours[i]);
totalHours= totalHours + hours[i];
charges[i]= calculateCharges(hours[i]);
totalCharges= totalCharges + charges[i];
}
printf("\nCars\t\tHours\t\tCharge");
for(i=0; i<NUMBER_OF_CARS; i++)
{
printf("\n");
printf("%d\t\t%.1f\t\t%.2f", cars[i], hours[i], charges[i]);
}
printf("\nTOTAL\t\t%.1f\t\t%.2f", totalHours, totalCharges);
return 0;
}
float calculateCharges(float hours)
{
float cHours=ceil(hours);
float charge=0.0;
if (cHours <= 3.0)
charge=2.00;
else if (cHours>3.0 && cHours <= 17.0)
charge= ((cHours-3.0)*0.5)+2.0;
else
charge= 10.0;
return charge;
}
any idea why when i submit it to this site called webcat, i get this error message