Answer to Question #259433 in C for fas

Question #259433

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.


1
Expert's answer
2021-11-01T01:58:37-0400


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS