diff options
| author | Trevor Bouchillon <[email protected]> | 2022-11-09 13:05:51 -0800 |
|---|---|---|
| committer | Trevor Bouchillon <[email protected]> | 2022-11-09 13:05:51 -0800 |
| commit | 5c192354cba1dcb7ca2938ba34a757bfda56eb69 (patch) | |
| tree | a33d98150ae5d8a3fae857414d8b20dd24cbf3d4 /BlankConsoleLab/Lab2TrevorBouchillon.cpp | |
| parent | added output file (diff) | |
| download | cst116-lab2-daboochillin-5c192354cba1dcb7ca2938ba34a757bfda56eb69.tar.xz cst116-lab2-daboochillin-5c192354cba1dcb7ca2938ba34a757bfda56eb69.zip | |
final Commit
Diffstat (limited to 'BlankConsoleLab/Lab2TrevorBouchillon.cpp')
| -rw-r--r-- | BlankConsoleLab/Lab2TrevorBouchillon.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/BlankConsoleLab/Lab2TrevorBouchillon.cpp b/BlankConsoleLab/Lab2TrevorBouchillon.cpp new file mode 100644 index 0000000..b3d9a59 --- /dev/null +++ b/BlankConsoleLab/Lab2TrevorBouchillon.cpp @@ -0,0 +1,82 @@ +// +// Lab2 +// Trevor Bouchillon +// CST116 +// + +#include <iostream> +#include <math.h> +#include <stdio.h> + +using namespace std; + +using std::cout; +using std::cin; +using std::endl; +using std::pow; + +float UserInputTemp; +float WindSpeed; +char CorF; +float windchill; + + +float CelciusToFarenheit(float Celcius2Farenheit) { //function to turn celcius entries into farenheit. + Celcius2Farenheit = (UserInputTemp * (static_cast<float>(9) / 5)) + 32; + return Celcius2Farenheit; +} + +float GetTemp() { //function to collect temperature inputs + cout << "Please enter a temperature in Celcius or Farenheit: "; + cin >> UserInputTemp; + cout << "If you entered a temperature in Celcius please enter 'C' and if you entered a temperature in Farenheit please enter 'F'. "; + cin >> CorF; + + while (CorF != 'C' && CorF != 'F') { + cout << "Please enter either 'C' or 'F': "; + cin >> CorF; + } + if (CorF == 'F') { + while (UserInputTemp < -80 || UserInputTemp > 121) { + cout << "Please enter a temperature between -80 and 121." << endl; + cout << "Please enter a temperature in Farenheit: "; + cin >> UserInputTemp; + } + } + else if (CorF == 'C') { + while (UserInputTemp < -62 || UserInputTemp > 49.5) { + cout << "Please enter a temperature between -62 and 49.5." << endl; + cout << "Please enter a temperature in Celcius: "; + cin >> UserInputTemp; + } + cout << "The temperature you entered is " << CelciusToFarenheit(UserInputTemp) << " degrees in Farenheit." << endl; + } + return UserInputTemp; +} + +float GetWindSpeed() { //function to collect windspeed inputs + cout << "Please enter a wind speed in Miles Per Hour: "; + cin >> WindSpeed; + while (WindSpeed < 0 || WindSpeed > 231) { + cout << "Please enter a wind speed between 0 and 231 Miles Per Hour" << endl; + cout << "Please enter a wind speed in Miles Per Hour: "; + cin >> WindSpeed; + } + return WindSpeed; +} + +float WindChill() { //function to calculate windchill + windchill = 35.74 + (0.6215 * CelciusToFarenheit(UserInputTemp)) - (35.75 * pow(WindSpeed, 0.16)) + (0.4275 * CelciusToFarenheit(UserInputTemp) * pow(WindSpeed, 0.16)); + cout << "Based on your inputs of " << CelciusToFarenheit(UserInputTemp) << " and " << WindSpeed << ", the wind chill is " << windchill << "."; + return windchill; +} + +int main() +{ + GetTemp(); + GetWindSpeed(); + WindChill(); + + return 0; +} + |