i edited the code and fixed a few more bugs, then there's no compile error. But the output is really werid, all the spacing are not correct. The edited code is:
Code:
/* Calculates and prints parking charges. */
#include <stdio.h>
float calculateCharges( float );
int main()
{
float timeParked1, timeParked2, timeParked3;
printf( "Car %2d - hours parked: ", 1 ); /* Car 1 */
scanf( "%f", &timeParked1 );
printf( "Car %2d - hours parked: ", 2 ); /* Car 2 */
scanf( "%f", &timeParked2 );
printf( "Car %2d - hours parked: ", 3 ); /* Car 3 */
scanf( "%f", &timeParked3 );
printf( "%s%6s%6s", "Car", "Hours", "Charge" );
printf( "\n%d%6f%6.2f", 1, timeParked1, calculateCharges( timeParked1 ) );
printf( "\n%d%6f%6.2f", 2, timeParked2, calculateCharges( timeParked2 ) );
printf( "\n%d%6f%6.2f", 3, timeParked3, calculateCharges( timeParked3 ) );
return 0;
}
float calculateCharges( float parked )
{
float fee;
if ( parked <= 3 )
return 2.00;
else if ( parked > 3 ) {
fee = ( parked - 3 ) * 0.50 + 2;
return fee;
}
else if ( parked == 24 )
return 10.00;
else
return 0;
}
The output of the program is:
Car - 1 hours parked: 2
Car - 2 hours parked: Car 3 - hours parked: Car HoursCharge
1(non-float printf) (n
2(non-float printf) (n
3(non-float printf) (n
pls help thnx