car park charge according to vehicle type
Write a program called "Car Park Program" that, given the type of vehicle
('c' for car, 'b' for bus, 't' for truck) and the hours a vehicle spent in
the parking lot, returns the parking fee based on the rates shown below.
Car $2 per hour Bus $3 per hour Truck $4 per hour
This is my answer, but its wrong on line 16 where it says: ( if type==c )
why is it wrong???
#include <stdio.h>
main()
{
char type;
float hours, fee;
printf("\n\nCar Park Program: ");
printf("\n\n-----------------------------------");
printf("\n\nType of vehicle");
printf("\n\nc-Car");
printf("\n\nb-Bus");
printf("\n\nt-Truck");
printf("\n\nEnter type of vehicle: ");
scanf("%c", &type);
printf("Number of hours: ");
scanf("%f", &hours);
if (type==c)
{
fee=2*hours;
printf("\n\n\nParking fee: $.2f \n\n\n\n", fee);
}
if (type==b)
{
fee=3*hours;
printf("\n\n\nParking fee: $.2f \n\n\n\n", fee);
}
if (type==t)
{
fee=4*hours;
printf("\n\n\nParking fee: $.2f \n\n\n\n", fee);
}
}
No comments:
Post a Comment