Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that should calculate the fare for a cab ride based on the rates

ID: 3935916 • Letter: W

Question

Write a program that should calculate the fare for a cab ride based on the rates provided below. Ask the user to input distance (measured to 1/10 of mile), number of passengers, and if going to/coming from the airport. Calculate fare for trip using these rates:

Minimum fare: $5.00 (fares less than this rounded up to $3.50).

$1.80 per mile (charged by 1/10 of mile. 2.1 miles = $3.78).

1st additional passenger, if more than 1 rider: $1.00.

Each additional passenger (after 1st additional passenger): $0.50.

Airport surcharge: $2.00.

Explanation / Answer

#include<iostream.h>

#include<conio.h>

void main()

{

int distance, passengers,airport;

float fare;

cout<<"Enter the distance";

cin>>distance;

cout<<"Enter number of passengers";

cin>>passengers;

cout<<"Going 1 if going for/to aiport";

cin>>airport;

if(airport == 1)

{ fare = (distance*1.80) + 2;}

else

{fare = distance * 1.80; }

if(passenger<=1)

{

fare = fare + 1

}

else if(passenger >1)

{

fare = fare + 1 + (0.50* (passenger-1));

}

cout<<"The fare is"<<fare;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote