// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include using namespace std; const float MINFTEMP = -80; const float MAXFTEMP = 121; const float MINCTEMP = -62; const float MAXCTEMP = 49.5; const float MINWSPEED = 0; const float MAXWSPEED = 231; const string YES_WORD = "yes"; void convertValueToFarenheit(float& celsiusvalue); float calculateWindChill(float temp, float wind_speed); void outputData(float temp, float wind_speed, float wind_chill); int main() { float temp = -81; float wind_speed = -1; bool ferenheit = true; string input_word; cout << "Will you be inputting your data in celcius? If yes, then please type 'yes': "; cin >> input_word; cout << endl; cin.clear(); if (input_word == YES_WORD) { ferenheit = false; } while ( (ferenheit && ((MINFTEMP > temp) || (MAXFTEMP < temp))) || (!ferenheit && ((MINCTEMP > temp) || (MAXCTEMP < temp))) ) { if (ferenheit) { cout << "Please input a temperature in Ferenheit, it must not be less than " << MINFTEMP << "F or greater than " << MAXFTEMP << "F.: "; } else { cout << "Please input a temperature in Celcius, it must not be less than " << MINCTEMP << "C or greater than " << MAXCTEMP << "C.: "; } cin >> temp; cout << endl; cin.clear(); } if (!ferenheit) convertValueToFarenheit(temp); while ((MINWSPEED > wind_speed) || MAXWSPEED < wind_speed) { cout << "Please input a wind speed in Miles per Hour, it must not be less than " << MINWSPEED << "m/p or greater than " << MAXWSPEED << "m/p.: "; cin >> wind_speed; cout << endl; cin.clear(); } outputData(temp, wind_speed, calculateWindChill(temp, wind_speed)); return 0; } /// /// Edits the reference 'celsiusvalus' to conver it to Ferenheit; /// /// void convertValueToFarenheit(float& celsiusvalue) { celsiusvalue * (9.0 / 5.0); celsiusvalue += 32; } /// /// Calculates the wind chill and returns that from temp and wind_speed; /// /// /// /// float calculateWindChill(float temp, float wind_speed) { return 35.74 + .6215 * temp - 35.75 * powf(wind_speed, 0.16) + .4275 * temp * powf(wind_speed, 0.16); } /// /// Outputs the three inputs to the console with formatting; /// /// /// /// void outputData(float temp, float wind_speed, float wind_chill) { cout << "Temperature: " << temp << "F" << "\n Wind Speed: " << wind_speed << "m/p" << "\n Wind chill: " << wind_chill << endl; }