thank you for that. it makes so much more sense. I have now fiddle for well over 2 hours and believe I have done what I think is right. I am not sure however about 'v' in the equation.
this is the prompt I was give...
In cold weather, meteorologist report an index called the windchill factor, which takes into account the wind speed and the temperature. The index provides a measure of the chilling effect of wind at a given air temperature.
Windchill may be approximated by the formula:
w = 13.12 + (0.6215 * t) - (11.37 * v0.16) + (0.3965 * t * v0.016)
where v = wind speed in m/sec, t = temperature in degrees Celsius for t <= 10, w = windchill index (in degrees Celsius).
Write a program that computes the windchill index for a given temperature, input by the user. Your code should ensure that the restriction on the temperature is not violated. Functions should be:
void intro( ); // introduction to what the program does
float getTemp( ); // prompts the user to enter a temperature in Celsius
// Within this function, there should be data validation to make
// sure the value input is <= 10. If it isn't, there should be a
// loop that runs until the user inputs a valid number.
float computeWC(float); // computes the windchill index for the temperature input
void showWC(float, float); // shows the original temperature and the windchill index
Be sure you used functions in the <cmath> library, where appropriate.
then here is what I have types...
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
|
#include <iostream>
#include <cmath>
using namespace std;
//prototypes
void intro();
float getTemp();
float computeWC(float);
void showWC(float,float);
int main ()
{
float celsius;
float chillWind;
intro();
celsius = getTemp();
chillWind = computeWC(celsius);
showWC(celsius,chillWind);
return 0;
}
void intro()
{
cout << "\tCalculate the wind chill for any given temperature\n\n";
return;
}
float getTemp()
{
int cNum;
do
{ cout << "Enter a temperature in Celsius that is less than 10: ";
cin >> cNum;
}
while (cNum >= 11);
return cNum;
}
float computeWC(float cNum)
{
float windChill;
float v;
windChill = 13.12 + (.6215 * cNum) - (11.37 * pow(v,0.16)) + (.3965 * cNum * pow(v,.016));
return windChill;
}
void showWC (float cNum,float windChill)
{
cout << endl << cNum << " degrees Celsius" << endl << endl;
cout << "The wind chill index is " << windChill << endl;
return;
}
|