Write a program that should calculate the fare for a cab rid

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.

Solution

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

}

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), numb
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), numb

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site