In: Computer Science
C program and pseudocode for this problem.
A parking garage charges a $2.00 minimum fee to park for up to three hours and additional $0.50 per hour 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 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. Your output should display the car #, the hours entered and the total charge.
Sample Output:
The screenshots are attached below for reference.
Please follow them for proper output.
Program code to
copy:
#include <stdio.h>
float calculateCharges(int h){//calcuates and returns
charge
if(h<=3){
return 2.0;
}
else if((h>3) && (h<=6))
return 2+(0.5*(h-3));
else
return 10;
}
int main()
{
int h1,h2,h3;
float c1=0,c2=0,c3=0;
printf("Enter number of hours for customer1 :");//read hours parked
for 3 cars
scanf("%d",&h1);
printf("Enter number of hours for customer2 :");
scanf("%d",&h2);
printf("Enter number of hours for customer3 :");
scanf("%d",&h3);
c1=calculateCharges(h1);//call functions
c2=calculateCharges(h2);
c3=calculateCharges(h3);
printf("car#%d %d %f\n",1,h1,c1);//print the returned values
printf("car#%d %d %f\n",2,h2,c2);
printf("car#%d %d %f\n",3,h3,c3);
return 0;
}