calculating the wind chill Error:term does not evaluate to a function taking 1 arguments

closed account (DG6DjE8b)
Write a function that returns a windchill factor according to the following formula:

W = 13.12 + 0.6215*t – 11.37*v^0.16 + 0.3965*t*v^0.016
Where v is the wind speed in m/sec, t is the temperature in degrees Celsius: t<=10, and W is the windchill factor
(in degrees Celsius). Your function should compute windchill only for valid input temperatures (t<=10). Write a
test code for your function. Show windchill for six input pairs of values (t and v).

#include<iostream>
#include <math.h>
using namespace std;


double W (double V, double T);
double V(double V);
double T (double T);

int main ()
{

double W ;
double V ;
double T ;
char response;

cout<<"Enter the wind speed in meters per second :\n";
cin >> V;


cout << "Enter the temperature in Degree Celcius:\n";
cin >> T;


cout <<"This is the wind chill in your area"<<W<<endl;


cout << "do you want a go again ";
cin >> response;

if (response == 'Y')
{
cout << "type in the wind speed and temperature:\n";
}

if (response == 'N')
{
cout << "Good Bye:\n";
exit(0);
}

return 0;

}

double W (double V, double T)

{
W = (13.12 + 0.6215 * T - 11.37* V (0.16) + 0.3965* T * V (0.016));
return (1);
}
Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

You haven't told us the line number that's generating the error, but it's pretty obviously this one:

W = (13.12 + 0.6215 * T - 11.37* V (0.16) + 0.3965* T * V (0.016));

You've defined V as a double, i.e. a floating point number, so the expression V (0.16) makes no sense. That syntax is what you'd use for calling a function.

If you want to raise a number by a power, you should use the standard library function std::pow() :

http://www.cplusplus.com/reference/cmath/pow/

EDIT: Also, that W = ... is problematic. You haven't defined a variable called W within the scope of the function. That W will be interpreted as the name of the function, which is an rvalue, and can't have a value assigned to it.

Also, you've defined the function W() as returning a double, but the only return statement returns an integer, 1. Did you intend for it to return the result of the calculation?

Also, nowhere in your code do you ever actually call your W function. It won't do anything if you never call it!
Last edited on
Topic archived. No new replies allowed.