Don't understand error msg!

I really don't understand what this is telling me. Its the only error I get when I debug, but the error is holding me up.

1>Lab 7b.cpp(63): error C2082: redefinition of formal parameter 'rate'

Code is below. I would appreciate any help. Thanks.

#include <iostream>
using namespace std;


double PoolSize(double Length, double Width, double Depth, double &volume);
double Convert (double volume, double cubicfeet, double &gallons);
double FillTime(double gallons, double FillRate, double &Minutes);
double Cost(double gallons, double rate);

int main ()
{
double Length;
double Width;
double Depth;
double volume;
double gallons;
double rate=2.90;
const double cubicfeet = 7.48051948;
double FillRate;
double Minutes;

cout << "Insert the length: ";
cin >> Length;
cout << "Insert the width: ";
cin >> Width;
cout << "Insert the depth: ";
cin >> Depth;

cout << "The volume of the pool is: "<< PoolSize (Length, Width, Depth, volume) << "cubicfeet\n\n";
cout << "The pool holds: " << Convert (volume, cubicfeet, gallons) << " gallons of water\n\n";

cout << "Enter fill rate of the pool (in gallons per minute): ";
cin >> FillRate;
cout << "\n";
cout <<"The time it takes to fill the pool is: "<< FillTime (gallons, FillRate, Minutes) <<" minutes \n\n";

cout << " The Cost to fill the pool is $"<< Cost(gallons, rate);
system("pause");
}

double PoolSize(double Length, double Width, double Depth, double &volume)
{
volume = (Length*Width*Depth);
return volume;
}

double Convert(double volume, double cubicfeet, double &gallons)
{
cubicfeet = 7.48051948;
gallons = (volume*cubicfeet);
return gallons;
}

double FillTime(double gallons, double FillRate, double &Minutes)
{
Minutes = (gallons/FillRate);
return Minutes;
}

double Cost(double gallons, double rate)
{
double payment;
double rate=2.90;
if(gallons > 3000)
{
payment = gallons * rate;
}
else
{
payment = 15.50;
}
return payment;
}
You have already defined the variable rate in parameter section of the function cost. All you need to do is remove the double in front of rate in the code. Should look like this:

1
2
3
4
5
6
7
8
double Cost(double gallons, double rate)
{
double payment;
rate=2.90;
if(gallons > 3000)
{
payment = gallons * rate;
}
Worked like a charm. Thank You
Please consider using [code] for your code next time though
Topic archived. No new replies allowed.