Question: Problem 4 : Taxi Fare ( switch ) : Write a program to compute the total fare for a taxi ride using a switch statement

Problem 4: Taxi Fare (switch):
Write a program to compute the total fare for a taxi ride using a switch statement considering the following table:
\table[[Ride Type,Base Fare first 5 km ),Per-km fare (after 5 km )],[Standard (S),AED 10.5,AED 2.0],[Premium (P),AED 30.5,AED 3.5]]
The program prompts the user to insert the ride type ( S or P ) and the total distance travelled (a positive value in km only is accepted). The program should compute and display the final rate following:
If the distance is less than or equal to 5 km , charge the base fare.
If the distance is greater than 5 km , charge the base fare plus the additional distance multiplied by the per-km fare.
Problem 4 : Taxi Fare ( switch ) : Write a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!