Any ideas on way this doesn't run?

I can't figure out what the errors are telling me.

1>Lab 7a.cpp(20): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>Lab 7a.cpp(45): error C2082: redefinition of formal parameter 'volume'
1>Lab 7a.cpp(52): error C2082: redefinition of formal parameter 'gallons'
1>Lab 7a.cpp(53): error C2082: redefinition of formal parameter 'cubicfeet'
1>Lab 7a.cpp(53): warning C4305: 'initializing' : truncation from 'double' to 'const float'


Here's the code I have so far.


#include <iostream>
using namespace std;


float PoolSize(float Length, float Width, float Depth, float &volume);
float Convert (float volume, float const &cubicfeet, float gallons);
float FillTime(float gallons, float FillRate, float &Minutes);

int main ()
{
float Length;
float Width;
float Depth;
float volume;
float gallons;
const float cubicfeet = 7.48051948;
float FillRate;
float 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: "<< volume << "cubicfeet\n\n";
cout << "The pool holds: " << 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: "<< Minutes <<" minutes \n\n";

system("pause");
}

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

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

float FillTime(float gallons, float FillRate, float &Minutes)
{
Minutes = (gallons/FillRate);
return Minutes;
}
I perform a quick fix , but you must check it with the compiler to see if it's ok now...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#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);

int main ()
{
double Length;
double Width;
double Depth;
double volume;
double gallons;
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 << "Insert the volume: ";
cin >> volume;
cout << "Insert the gallons: ";
cin >> gallons;
cout << "Insert the minutes: ";
cin >> Minutes;
cout << "The volume of the pool is: "<< volume << "cubicfeet\n\n";
cout << "The pool holds: " << 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: "<< Minutes <<" minutes \n\n";

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;
}
Last edited on
Your prototype:
float Convert (float volume, float const &cubicfeet, float gallons);
Doesn't match your definition:
float Convert(float volume, const float cubicfeet, float &gallons)

I don't know why it's complaining about volume, though.
And because you didn't use function yet,I didn't check the function yet.Compile and run if it first kicks initialization and non-modify error.
I think I go it now. Thanks for your help.

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

int main ()
{
double Length;
double Width;
double Depth;
double volume;
double gallons;
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";

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;
}
Topic archived. No new replies allowed.