summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj2
-rw-r--r--BlankConsoleLab/cst116-lab2-stark.cpp19
2 files changed, 11 insertions, 10 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj
index f6479cd..68fc265 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj
@@ -24,7 +24,7 @@
<ProjectGuid>{3cecade6-3e15-4852-bd24-65bfe5d3a3aa}</ProjectGuid>
<RootNamespace>BlankConsoleLab</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
- <ProjectName>Lab2</ProjectName>
+ <ProjectName>cst116-lab2-stark</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
diff --git a/BlankConsoleLab/cst116-lab2-stark.cpp b/BlankConsoleLab/cst116-lab2-stark.cpp
index 7d1352a..9063fd8 100644
--- a/BlankConsoleLab/cst116-lab2-stark.cpp
+++ b/BlankConsoleLab/cst116-lab2-stark.cpp
@@ -45,7 +45,7 @@ void inputTemp(float& cTemp, float& fTemp) {
if (tempType != 'f' && tempType != 'c') {
cout << "Input the character 'c' or 'f'!" << endl;
}
- } while (tempType != 'f' && tempType != 'c');
+ } while (tempType != 'f' && tempType != 'c'); //Loops if incorrect char input
if (tempType == 'c') {
cout << "What is the temperature in Celcius (-62 - 49.5 degrees)?" << endl;
@@ -56,7 +56,7 @@ void inputTemp(float& cTemp, float& fTemp) {
cout << "Input a value between -62 and 49.5 degrees!" << endl;
}
fTemp = tempConverter(cTemp, 0);
- } while (cTemp < cMin || cTemp > cMax);
+ } while (cTemp < cMin || cTemp > cMax); //Loops if input is not in range
}
else {
cout << "What is the temperature in Fahrenheit (-80 - 121 degrees)?" << endl;
@@ -67,23 +67,23 @@ void inputTemp(float& cTemp, float& fTemp) {
cout << "Input a value between -80 and 121 degrees!" << endl;
}
cTemp = tempConverter(fTemp, 1);
- } while (fTemp < fMin || fTemp > fMax);
+ } while (fTemp < fMin || fTemp > fMax); //Loops if input is not in range
}
}
// Direction is 0 if going celcius to fahrenheit and 1 if going fahrenheit to celcius
float tempConverter(float temp, bool dirc) {
- float cTemp;
+ float conTemp; //Temperature after conversion, either celcius of fahrenheit
if (dirc == 0) {
- cTemp = (temp * (9.0 / 5.0)) + 32;
+ conTemp = (temp * (9.0 / 5.0)) + 32;
}
else {
- cTemp = (temp - 32) * (5.0 / 9.0);
+ conTemp = (temp - 32) * (5.0 / 9.0);
}
- return cTemp;
+ return conTemp;
}
//Gets wind speed and passes it back through reference
@@ -95,11 +95,12 @@ void inputWind(float& windS) {
if (windS < 0 || windS > 231) {
cout << "Input a value between 0 and 231 miles per hour!" << endl;
}
- } while (windS < 0 || windS > 231);
+ } while (windS < 0 || windS > 231); //Loops if input is not in range
}
+//Converts a temperature in fahrenheit and a wind speed in miles per hour to windchill
float windChillCalc(float fTemp, float windS) {
- float windC;
+ float windC;
windC = 35.74 + (0.6125 * fTemp) - (35.75 * pow(windS, 0.16)) + (0.4275 * fTemp * pow(windS, 0.16)); //Formula from https://www.weather.gov/media/epz/wxcalc/windChill.pdf
return windC;
}