Peter runs a vehicle rental center. The vehicles are of three types, MICRO, MINI and SUV. The customer who travels in MICRO will pay Rs 15 per kilometer. The customer who travels in MINI will pay Rs 20 per kilometer and the customer who travels in SUV will pay Rs 25 per kilometer.
A software need to be developed to compute the cost of travelling by the customer with following requirements.
a. The distance travelled by customer need to be captured.
b. The type of vehicle to be captured (M for Micro, m for mini, S for SUV).
c. Check the type of vehicle.
d. Compute the final cost of the travel depending on the vehicle.
Display the final cost.
#include <stdio.h>
int main()
{
int dist;
printf("\nEnter distance trvelled: ");
scanf("%d",&dist);
char type;
printf("\nEnter type of vehicle (M for Micro, m for mini, S for SUV): ");
scanf("%c",&type);
int price;
if(type=='M')
price=15*dist;
else if(type=='m')
price=20*dist;
else if(type=='S')
price=25*dist;
printf("\nFinal Price = %d",price);
return 0;
}
Comments
Leave a comment