can someone make this code work?

#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

double getDistance();
int getPassengerCount();
double calculateFare (double &distance, int &count, double &total);

const double rate = 2.40;
const double surcharge = 1.20;

int main(int argc, char *argv[])
{
double distance = 0;
int count = 0;

cout<<"Enter distance traveled: ";
cin>>distance;

cout<<"Enter number of passengers: ";
cin>> count;

calculateFare(distance , count , total);

cout<< "It will cost \$"<<total<< " for " << count <<
" passenger(s) to travel "<< distance << "miles in my taxi."<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}
double calculateFare(double d, int c, double t)
{
const double rate = 2.40;
const double surcharge = 1.20;

if (count = 1)
{
t = d * rate;
}
else
{
t= (d * rate) + (surcharge * count);
}
}
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253`` ``````#include #include #include using namespace std; double getDistance(); int getPassengerCount(); float calculateFare (double distance, int count);//changed to float because it's better for money value const double rate = 2.40; const double surcharge = 1.20; int main(int argc, char *argv[]) { double distance = 0; int count = 0; float total = 0;//added a total variable cout<<"Enter distance traveled: "; cin>>distance; cout<<"Enter number of passengers: "; cin>> count; total=calculateFare(distance , count);//made it so a variable total is equal to an outcome of function calculateFare cout<< "It will cost \$"<
Last edited on
it worked beautifuly on my compiler, my compiler has been more forgiving though, whats wrong with it??
thanks!
Topic archived. No new replies allowed.