// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. /* * Benjamin Smith * CST116 Lab 2 */ #include #include using namespace std; const float temp_min_F = -80, temp_max_F = 121, temp_min_C = -61, temp_max_C = 49.5, wind_min = 0, wind_max = 231; string input = ""; float temperature = 0, wind_speed = 0, wind_chill = 0;; float Temp_Conversion(float temp) { temp *= 1.8; temp += 32; return temp; } float Wind_Chill(float temp, float speed) { return 35.74 + (.6215 * temp) - (35.75 * pow(speed, .16)) + (.4275 * temp * pow(speed, .16)); } int main() { //Temperature type input cout << "Before you input a temperature value, you must first determine if it's in fahrenheit or celsius." << endl; cout << "Please input 'F' for fahrenheit or 'C' for celsius: "; cin >> input; while (input != "F" && input != "C") { cout << "That input is invalid." << endl; cout << "Make sure your input is capitalized." << endl; cout << "Please input 'F' for fahrenheit or 'C' for celsius: "; cin >> input; } //Temperature value input if (input == "C") cout << endl << endl << "Now please input a temperature between the range " << temp_min_C << " to " << temp_max_C << ": "; if (input == "F") cout << endl << endl << "Now please input a temperature between the range " << temp_min_F << " to " << temp_max_F << ": "; cin >> temperature; if (input == "C") { while (temperature < temp_min_C || temperature > temp_max_C) { cout << endl; cout << "That input is invalid." << endl << "Your value must be between " << temp_min_C << " and " << temp_max_C << "." << endl; cout << "Please input the temperature again: "; cin >> temperature; } } else { while (temperature < temp_min_F || temperature > temp_max_F) { cout << endl; cout << "That input is invalid." << endl << "Your value must be between " << temp_min_F << " and " << temp_max_F << "." << endl; cout << "Please input the temperature again: "; cin >> temperature; } } //Wind Speed value input cout << endl << endl << "Now please input a wind speed between the range " << wind_min << " to " << wind_max << ": "; cin >> wind_speed; while (wind_speed < wind_min || wind_speed > wind_max) { cout << endl; cout << "That input is invalid." << endl << "Your value must be between " << wind_min << " and " << wind_max << "." << endl; cout << "Please input the wind speed again: "; cin >> wind_speed; } //Convert Celsius to Fahrenheit if (input == "C") Temp_Conversion(temperature); //Calculate the Wind Chill wind_chill = Wind_Chill(temperature, wind_speed); cout << endl << endl << endl << wind_chill; }