summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorWyatt <[email protected]>2022-11-08 21:03:04 -0800
committerWyatt <[email protected]>2022-11-08 21:03:04 -0800
commit440863931dff8864f9cca1e62ff22f24dfd9088f (patch)
tree2e2be70672abc7d58f3d30ff538b4365202f42b4 /BlankConsoleLab/BlankConsoleLab.cpp
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-lab2-johnson-440863931dff8864f9cca1e62ff22f24dfd9088f.tar.xz
cst116-lab2-johnson-440863931dff8864f9cca1e62ff22f24dfd9088f.zip
lab doneHEADmaster
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp100
1 files changed, 96 insertions, 4 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;
}