Okay, you're declaring two instances of your variables: double temp, rel_humidity, wind_spd; are declared and local to the functions main() and okay_to_spray(). Assigning values to these variables in main() is not going to affect the variables in okay_to_spray()
You have three options:
Make the variables double temp, rel_humidity, wind_spd; global, and remove their declarations from your functions eg:
Code:
#include <iostream>
#include <string>
using namespace std;
bool Okay_to_spray();
double temp, rel_humidity, wind_spd;
int main()
{
cout << "Input the temperature, relative humidity and the wind speed of our plane: \n";
cin >> temp >> rel_humidity >> wind_spd;
cout << "The plane's temperature is " << temp << " its relative humidity "
<< rel_humidity << " and its wind speed is " << wind_spd << ".\n";
cout << (Okay_to_spray()) ? "true" : "false" << "\n";
return 0;
}
bool Okay_to_spray()
{
{
if (temp == 70)
if (rel_humidity >= 15 && rel_humidity <= 35)
if (wind_spd == 10)
return true;
else
return false;
}
}
2. You can pass them to your function okay_to_spray()
Code:
#include <iostream>
#include <string>
using namespace std;
bool Okay_to_spray(double, double, double);
int main()
{
double temp, rel_humidity, wind_spd;
cout << "Input the temperature, relative humidity and the wind speed of our plane: \n";
cin >> temp >> rel_humidity >> wind_spd;
cout << "The plane's temperature is " << temp << " its relative humidity "
<< rel_humidity << " and its wind speed is " << wind_spd << ".\n";
cout << (Okay_to_spray(temp, rel_humidity, wind_spd)) ? "true" : "false" << "\n";
return 0;
}
bool Okay_to_spray(double temperature, double humid, double wind)
{
{
if (temperature == 70)
if (humid >= 15 && humid <= 35)
if (wind == 10)
return true;
else
return false;
}
}
3. You can create a "spray" structure.
Code:
#include <iostream>
#include <string>
using namespace std;
struct spraystr
{
double temperature;
double rel_humidity;
double wind_spd;
};
bool Okay_to_spray(spraystr);
int main()
{
spraystr spray;
cout << "Input the temperature, relative humidity and the wind speed of our plane: \n";
cin >> spray.temperature >> spray.rel_humidity >> spray.wind_spd;
cout << "The plane's temperature is " << spray.temperature << " its relative humidity "
<< spray.rel_humidity << " and its wind speed is " << spray.wind_spd << ".\n";
cout << (Okay_to_spray(spray)) ? "true" : "false" << "\n";
return 0;
}
bool Okay_to_spray(spraystr sprayStructure)
{
{
if (sprayStructure.temperature == 70)
if (sprayStructure.rel_humidity >= 15 && humid <= 35)
if (sprayStructure.wind_spd == 10)
return true;
else
return false;
}
}
You also had other syntatical errors in your code which I fixed, like not calling your function, incorrect return type, not stating the return type, and I don't know what you were doing with the char variable "spray" etc. Personally I'd go with option 2 or 3.