I would like to know how to use the void function to output results based on condition. I am trying to create a windchill calculator.
What can I add to make the program below output the air temperature below speeds of 4.8kph?
What can I do to void print_result to print various statements – like “wear 3 layers” for -20 to -30 windchill (WC) or “wear 5 layers” for -30 to -40? Thanks to those who can help!
#include <iostream>
#include <cmath>
using namespace std;
bool is_cold(double V)
{
bool is_windy;
if (V <= 4.8)
{
is_windy = false;
}
else
is_windy = true;
return (is_windy);
}
int windchill_index(double T, double V)
{
int WC;
WC = 13.12 + 0.6215*T - 11.37*pow(V,0.16) + 0.3965*T*pow(V, 0.16);
return (WC);
}
void print_result(double WC)
{
cout << "From the input for tempearature and wind speed, the wind chill is: "<< WC << endl;
}
int main()
{
double WC = 0, T = 0, V = 0;
bool is_windy = false;
if (!is_windy)
{
cout << "Please enter the air temperature in Celsius followed by the windpseed in kph: " << endl;
cin >> T;
cin >> V;
is_windy = is_cold(V);
}
WC = windchill_index(T, V);
print_result (WC);
return 0;
}
Are you familiar with boolean logic operators
and(&&) andor(||)? Also be sure to test at the boundary conditions (-20, -30, -40) to make sure you’re getting the results you want!EDIT:: To answer your question from the comments: