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.
/*
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.
*/
#define RATE_MICRO 15
#define RATE_MINI 20
#define RATE_SUV 25
#define MICRO 'M'
#define MINI 'm'
#define SUV 'S'
main()
{
int Distance,Rate,Cost,Flag=1;
char Vehicle,c=0;
while(Flag)
{
printf("\nPress m for MICRO Vehicle (%d per Km.): ",RATE_MICRO);
printf("\nPress M for MINI Vehicle (%d per Km.): ",RATE_MINI);
printf("\nPress S for SUV Vehicle (%d per Km.): ",RATE_SUV);
c=0;
while(c==0)
{
printf("\n\t\t\tSelect Option(m/M/S): "); scanf("%c",&Vehicle);
if(Vehicle=='m' || Vehicle=='M' || Vehicle=='S') c=1;
if(Vehicle=='m') Rate = RATE_MICRO;
if(Vehicle=='M') Rate = RATE_MINI;
if(Vehicle=='S') Rate = RATE_SUV;
}
printf("\n\nEnter the distance travelled (Kms): "); scanf("%d",&Distance);
Cost = Distance*Rate;
printf("\n\nTotal Cost = US $ %d",Cost);
printf("\n\nPress 1 to Continue or 0 to EXIT: "); scanf("%d",&Flag);
}
}
Comments
Leave a comment