// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include #include using namespace std; using std::cout; using std::cin; using std::endl; using std::pow; int selectType(); float getTemp(int& select); float calcTemp(float& temp); float getWindSpeed(); void calcWindChill(float temp, float windSpeed); // function main, no inputs, returns 0 int main() { float temp; int select = 0; float windSpeed = 0; select = selectType(); temp = getTemp(select); if (select == 2) temp = calcTemp(temp); windSpeed = getWindSpeed(); calcWindChill(temp, windSpeed); return 0; } // function selectType, no inputs, returns select int selectType() { char choose = '0'; int select = 0; while (select != 1 && select != 2) { cout << "Enter temperature in Fahrenheit or Celsius?" << endl << "[1] Fahrenheit" << endl << "[2] Celsius" << endl; cout << "Selection: "; cin >> choose; if (choose == '1') select = 1; else if (choose == '2') select = 2; else cout << "Please enter only 1 or 2." << endl; } return select; } // function getTemp, inputs select, returns temp float getTemp(int& select) { float temp =-100; const int minC = -62; const int maxC = 49.5; const int minF = -80; const int maxF = 121; if (select == 1) { while (temp < minF || temp > maxF) { cout << endl << "Enter temperature: "; cin >> temp; if (temp < minF || temp > maxF) cout << endl << "Please enter between " << minF << " and " << maxF << "." << endl; } } if (select == 2) { while (temp < minC || temp > maxC) { cout << endl << "Enter temperature: "; cin >> temp; if (temp < minC || temp > maxC) cout << endl << "Please enter between " << minC << " and " << maxC << "." << endl; } } return temp; } // function calcTemp, nputs temp, returns temp float calcTemp(float& Celsius) { float Fahrenheit = 0; Fahrenheit = 32 + ((9 * Celsius) / 5); return Fahrenheit; } // function getWindSpeed, no inputs, returns windSpeed float getWindSpeed() { float windSpeed = -100; { while (windSpeed < 0 || windSpeed > 231) { cout << endl << "Enter wind speed in MPH: "; cin >> windSpeed; if (windSpeed < 0 || windSpeed > 231) cout << endl << "Please enter between " << 0 << " and " << 231 << "." << endl; } } return windSpeed; } // function getWindChill, inputs temp and windSpeed, no return void calcWindChill(float temp, float windSpeed) { float windChill = 0; windChill = 35.74 + 0.6215 * temp - 35.75 * pow(windSpeed, 0.16) + 0.4275 * temp * pow(windSpeed, 0.16); cout << endl << windChill; }