aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprestonderek <[email protected]>2022-11-06 19:23:07 -0800
committerprestonderek <[email protected]>2022-11-06 19:23:07 -0800
commitcfe4e73c1f45caaacfd092e6fc292d2f785a846f (patch)
tree13e7f071f44a18bcdfcab490e0d7cfb2d99c18f4
parentAdd files via upload (diff)
downloadcst116-lab2-prestonderek-cfe4e73c1f45caaacfd092e6fc292d2f785a846f.tar.xz
cst116-lab2-prestonderek-cfe4e73c1f45caaacfd092e6fc292d2f785a846f.zip
Commit all for finish of project
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp109
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj12
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj.filters4
-rw-r--r--BlankConsoleLab/CST116-Lab2-Output-Preston.txt38
-rw-r--r--BlankConsoleLab/CST116-Lab2-Pseudocode-Preston.txt81
5 files changed, 238 insertions, 6 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index ed5f807..c7b68f7 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -2,6 +2,9 @@
//
#include <iostream>
+#include <iomanip>
+#include <string>
+#include <cmath>
using namespace std;
@@ -9,8 +12,110 @@ using std::cout;
using std::cin;
using std::endl;
-int main()
+float far;
+float cel;
+float mph;
+float newFar;
+float chill;
+
+const int celmin = -62;
+const float celmax = 49.5;
+const int farmin = -80;
+const int farmax = 121;
+const int mphmin = 0;
+const int mphmax = 231;
+
+string check;
+const string celcheck = "c";
+
+float celtofar(float cel);
+float getParam(float& far, float& mph);
+float windchill(float far, float mph);
+float getMPH(float& mph);
+
+int main() // calls functions and then displays the fahrenheit and windchill at the end
+
{
- cout << "Hello World!\n";
+ far = 0.0;
+ cel = 0.0;
+ mph = 0.0;
+
+ cout << "Do you want to enter fahrenheit or celcius? Enter f or c" << endl;
+ cin >> check;
+
+ if (check == celcheck)
+ {
+ celtofar(cel);
+ far = newFar;
+ getMPH(mph);
+ }
+ else
+ getParam(far, mph);
+
+ windchill(far, mph);
+
+ cout << "You entered " << far << "F" << endl;
+ cout << "For " << far << " degrees F and " << mph << " MPH wind speed, the windchill is: " << chill;
+
+ return 0;
}
+float getParam(float& far, float& mph) //gets fahrenheit and wind speed from user
+{
+ cout << "Please enter your fahrenheit temp:" << endl;
+ cout << "Must be between " << farmin << " and " << farmax << endl;
+ cin >> far;
+ while (far < farmin || far > farmax)
+ {
+ cout << "Please enter your fahrenheit temp:" << endl;
+ cout << "Must be between " << farmin << " and " << farmax << endl;
+ cin >> far;
+ }
+ cout << "Please enter your wind speed in mph:" << endl;
+ cout << "Must be between " << mphmin << " and " << mphmax << endl;
+ cin >> mph;
+ while (mph < mphmin || mph > mphmax)
+ {
+ cout << "Please enter your wind speed in mph:" << endl;
+ cout << "Must be between " << mphmin << " and " << mphmax << endl;
+ cin >> mph;
+ }
+ return far, mph;
+}
+
+float celtofar(float cel) //calculates celcius to fahrenheit and returns the value
+{
+ cout << "Please enter your celcius temp:" << endl;
+ cout << "Must be between " << celmin << " and " << celmax << endl;
+ cin >> cel;
+ while (cel < celmin || cel > celmax)
+ {
+ cout << "Please enter your celcius temp:" << endl;
+ cout << "Must be between " << celmin << " and " << celmax << endl;
+ cin >> cel;
+ }
+ newFar = (9 / 5) * cel + 32;
+ return newFar;
+}
+
+float windchill(float far, float mph) //calculates wind chill and returns it
+{
+ chill = 35.74 + (.6215 * far) - (35.75 * pow(mph, .16)) + (.4275 * pow(far, .16));
+ return chill;
+}
+
+float getMPH(float& mph) //gets mph only for when you select celcius function
+{
+ cout << "Please enter your wind speed in mph:" << endl;
+ cout << "Must be between " << mphmin << " and " << mphmax << endl;
+ cin >> mph;
+ while (mph < mphmin || mph > mphmax)
+ {
+ cout << "Please enter your wind speed in mph:" << endl;
+ cout << "Must be between " << mphmin << " and " << mphmax << endl;
+ cin >> mph;
+ }
+ return mph;
+}
+
+
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj
index db2e734..a1633e8 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj
@@ -29,26 +29,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -141,6 +141,10 @@
<ItemGroup>
<ClCompile Include="BlankConsoleLab.cpp" />
</ItemGroup>
+ <ItemGroup>
+ <Text Include="CST116-Lab2-Output-Preston.txt" />
+ <Text Include="CST116-Lab2-Pseudocode-Preston.txt" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
index aca1dd9..e98d538 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
@@ -19,4 +19,8 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
+ <ItemGroup>
+ <Text Include="CST116-Lab2-Pseudocode-Preston.txt" />
+ <Text Include="CST116-Lab2-Output-Preston.txt" />
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/BlankConsoleLab/CST116-Lab2-Output-Preston.txt b/BlankConsoleLab/CST116-Lab2-Output-Preston.txt
new file mode 100644
index 0000000..971cc63
--- /dev/null
+++ b/BlankConsoleLab/CST116-Lab2-Output-Preston.txt
@@ -0,0 +1,38 @@
+Output run for F input
+
+Do you want to enter fahrenheit or celcius? Enter f or c
+f
+Please enter your fahrenheit temp:
+Must be between -80 and 121
+-100
+Please enter your fahrenheit temp:
+Must be between -80 and 121
+40
+Please enter your wind speed in mph:
+Must be between 0 and 231
+245
+Please enter your wind speed in mph:
+Must be between 0 and 231
+130
+You entered 40F
+For 40 degrees F and 130 MPH wind speed, the windchill is: -16.5232
+
+Output run for C input
+
+Do you want to enter fahrenheit or celcius? Enter f or c
+c
+Please enter your celcius temp:
+Must be between -62 and 49.5
+-70
+Please enter your celcius temp:
+Must be between -62 and 49.5
+50
+Please enter your celcius temp:
+Must be between -62 and 49.5
+43.5
+Please enter your wind speed in mph:
+Must be between 0 and 231
+210.4
+You entered 75.5F
+For 75.5 degrees F and 210.4 MPH wind speed, the windchill is: -0.615265
+
diff --git a/BlankConsoleLab/CST116-Lab2-Pseudocode-Preston.txt b/BlankConsoleLab/CST116-Lab2-Pseudocode-Preston.txt
new file mode 100644
index 0000000..5784962
--- /dev/null
+++ b/BlankConsoleLab/CST116-Lab2-Pseudocode-Preston.txt
@@ -0,0 +1,81 @@
+Pseudocode for Lab 2
+
+float cel
+float far
+float mph
+float chill
+float newFar
+
+const min/max for far, cel, mph
+
+string check
+const string celcheck
+
+float celtofar(cel)
+float getParam(far&, mph&)
+float windchill(far, mph)
+float getMPH(mph&)
+
+main begin
+ far = 0
+ cel = 0
+ mph = 0
+
+ print do you want to enter cel or far
+ input check
+
+ if check == celcheck
+ celtofar(cel)
+ far = newFar
+ getMPH(mph)
+ else
+ getParam(far, mph)
+
+ windchill(far, mph)
+
+ print you entered + far + F
+ print for + far + degrees F and + mph + MPH wind speed + the windchill is + chill
+
+end main funciton
+
+float getParam(float& far, float& mph)
+ print enter far temp
+ print must be between farmin and farmax
+ input far
+ while (far < farmin OR far > farmax)
+ print enter far temp
+ print must be between farmin and farmax
+ input far
+ print enter wind speed in mph
+ print must be between mphmin and mphmax
+ input mph
+ while (mph < mphmin OR mph > mphmax)
+ print enter wind speed in mph
+ print must be between mphmin and mphmax
+ input mph
+ return far, mph
+
+float celtofar(float cel)
+ print enter your cel temp
+ print must be between celmin and celmax
+ input cel
+ while (cel < celmin OR cel > celmax)
+ print enter your cel temp
+ print must be between celmin and celmax
+ input cel
+ newFar = (9/5) x cel + 32
+ return newFar
+
+float getMPH(float& mph)
+ print enter wind speed in mph
+ print must be between mphmin and mphmax
+ input mph
+ while (mph < mphmin OR mph > mphmax)
+ print enter wind speed in mph
+ print must be between mphmin and mphmax
+ input mph
+ return mph
+
+float windchill(float far, float mph)
+ chill = 35.74 + (.6215 * far) - (35.75 * mph^.16) + (.4275 * mph^.16)
+ return chill \ No newline at end of file