This is the program
A parking garage charges $2 for minimum fee to park up to 3 hours and then a $.50 per hour charge after the 3rd hour. The maximum charge for any 24 hour parking is $10. Assume no car parks longer than 24 hrs, write a program that calculates and prints the parking charge for each of 3 customer. Result should be printed in tabular format. Hint: use function called calculateCHarge to determine charge for each customer
Code:
#include <stdio.h>
minfee = 2;
int main()
{
int car1,car2,car3,hour,hour2,hour3,charge1,charge2,charge3,
totalhour,totalcharge,minfee;
printf("Enter car number\n");
scanf("%d", &car1);
printf("How many hour did the car park\n");
scanf("%d", &hour);
if (hour>=3) {
charge1 = (minfee+hour*.50); }
else {
charge1 = 2.00; }
printf("Enter car number\n");
scanf("%d", &car2);
printf("How many hour did the car park\n");
scanf("%d", &hour2);
if (hour>=3) {
charge2 = (minfee+hour*.50); }
else {
charge2 = 2.00; }
printf("Enter car number\n");
scanf("%d", &car3);
printf("How many hour did the car park\n");
scanf("%d", &hour3);
if (hour>=3) {
charge3 = (minfee+hour*.50); }
else {
charge3 = 2.00; }
totalhour=(hour+hour2=hour3);
printf("%d", totalhour);
totalcharge=(charge1+charge2+charge3);
printf("%d", totalcharge);
return 0;
}
Heres how output should be
Car Hours Charge
1 1.5 2.00
2 4.0 2.50
3 24.0 10.00
Total 29.5 14.50