// 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); 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; } 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; } 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 < minC && temp > maxC) { cout << endl << "Enter temperature: "; cin >> temp; if (temp < minC || temp > maxC) cout << endl << "Please enter between " << minC << " and " << maxC << endl; } } if (select == 2) { 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; } } return temp; } float calcTemp(float& Celsius) { float Fahrenheit = 0; Fahrenheit = (9 / 5) * Celsius + 32; return Fahrenheit; } float getWindSpeed() { float windSpeed = 0; cout << endl << "Enter wind speed in MPH: "; cin >> windSpeed; return windSpeed; } 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; }