A new taxi service based on electric vehicles is offering services within a metro city. Following is the fare chart in the type of taxi used to commute and price per kilometer. Create a program to calculate total fare depending distance travelled in kilometers.
Answers
Answered by
0
Answer:
im not sure
Explanation:
Answered by
0
Answer:
#include <iostream>
using namespace std;
int main() {
int ch;
double d, fare, tfare;
cout<<"\nType 1 for micro taxi.";
cout<<"\nType 2 for mcro taxi.";
cout<<"\nType 3 for shared taxi.";
cout<<"\nEnter taxi type: ";
cin>>ch;
cout<<"\nEnter the distance travelled: ";
cin>>d;
switch(ch)
{
case 1:
fare = 10.05;
break;
case 2:
fare = 15.05;
break;
case 3:
fare = 7.05;
break;
}
tfare = fare*d;
cout<<"\nTotal fare = "<<tfare;
return 0;
}
Explanation:
- Start the program by declaring all the necessary variables.
- Take the taxi type and distance traveled as inputs from the user.
- We use the switch case to select the fare depending on the taxi type.
- The total fare is calculated by multiplying the distance by the fare.
- The total fare is printed.
#SPJ3
Attachments:
Similar questions