diff options
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 100 | ||||
| -rw-r--r-- | LabResults.txt | 14 | ||||
| -rw-r--r-- | psuedocode.txt | 11 |
3 files changed, 120 insertions, 5 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index ed5f807..eb11344 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -5,12 +5,104 @@ using namespace std; -using std::cout; -using std::cin; -using std::endl; +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() { - cout << "Hello World!\n"; + 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; +} + +/// <summary> +/// Edits the reference 'celsiusvalus' to conver it to Ferenheit; +/// </summary> +/// <param name="celsiusvalue"></param> +void convertValueToFarenheit(float& celsiusvalue) +{ + celsiusvalue * (9.0 / 5.0); + celsiusvalue += 32; +} +/// <summary> +/// Calculates the wind chill and returns that from temp and wind_speed; +/// </summary> +/// <param name="temp"></param> +/// <param name="wind_speed"></param> +/// <returns></returns> +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); +} +/// <summary> +/// Outputs the three inputs to the console with formatting; +/// </summary> +/// <param name="temp"></param> +/// <param name="wind_speed"></param> +/// <param name="wind_chill"></param> +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; } diff --git a/LabResults.txt b/LabResults.txt index bfe34d2..abaf139 100644 --- a/LabResults.txt +++ b/LabResults.txt @@ -1 +1,13 @@ -RunResults
\ No newline at end of file +RunResults + +Will you be inputting your data in celcius? If yes, then please type 'yes': yes + +Please input a temperature in Celcius, it must not be less than -62C or greater than 49.5C.: 12 + +Please input a wind speed in Miles per Hour, it must not be less than 0m/p or greater than 231m/p.: 500 + +Please input a wind speed in Miles per Hour, it must not be less than 0m/p or greater than 231m/p.: 23 + +Temperature: 44F + Wind Speed: 23m/p + Wind chill: 35.1097 diff --git a/psuedocode.txt b/psuedocode.txt new file mode 100644 index 0000000..19668e3 --- /dev/null +++ b/psuedocode.txt @@ -0,0 +1,11 @@ +ask use if using celcius, if yes, they will type yes. Store whether they are in a bool. +while float temp is outside the defined bounds of celcius and ferenheit, as user to input a value. set temp to the input. + +if ferenheit is false, convertValueToFerenheit(temp) + +while wind_speed is outside the defined bounds of windspeed, as user to input a value, set wind_speed to input. + + +outputData(temp, wind_speed, calculateWindChill(temp, wind_speed)); + +return
\ No newline at end of file |