Ok... so I basically have the program doing what I need it to but I have to write it as a function and I am getting stuck there. Have a look and let me know what you think. Thanks.
Code:
//A parking garage charges a $2.00 minimum fee to park for up to three hours
//and an additional $0.50 per hour for each hour or part thereof over 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 calculateCharges to determine
//the charge for each customer.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
int car;
float minfee = 2.00, maxfee = 10.00 , hours, totalcharge, totalhours,
calculateCharge;
totalcharge = 0;
totalhours = 0;
car = 1;
while( car < 4 ){
printf( "enter the hours parked: " );
scanf( "%f",&hours );
if( hours <= 3 ) {
calculateCharge = minfee;
}
else {
calculateCharge = ( (hours - 3) * 0.5 + minfee );
}
if( calculateCharge > maxfee ) {
calculateCharge = ( maxfee );
}
car = car;
printf( "Car#: %d ", car );
totalhours = hours;
printf( "Hours: %.2f ",totalhours );
totalcharge = calculateCharge;
printf( "Charge: $%.2f\n",totalcharge );
car = car + 1;
}
system("PAUSE");
return 0;
}