aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CST116-Lab2-Preston.cpp122
-rw-r--r--CST116-Lab2-Preston.sln31
-rw-r--r--CST116-Lab2-PseudoCode-Preston.txt81
3 files changed, 234 insertions, 0 deletions
diff --git a/CST116-Lab2-Preston.cpp b/CST116-Lab2-Preston.cpp
new file mode 100644
index 0000000..4d15f4e
--- /dev/null
+++ b/CST116-Lab2-Preston.cpp
@@ -0,0 +1,122 @@
+// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
+//
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <cmath>
+
+using namespace std;
+
+using std::cout;
+using std::cin;
+using std::endl;
+
+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
+
+{
+ 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/CST116-Lab2-Preston.sln b/CST116-Lab2-Preston.sln
new file mode 100644
index 0000000..8e981c8
--- /dev/null
+++ b/CST116-Lab2-Preston.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31911.196
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlankConsoleLab", "BlankConsoleLab\BlankConsoleLab.vcxproj", "{3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Debug|x64.ActiveCfg = Debug|x64
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Debug|x64.Build.0 = Debug|x64
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Debug|x86.ActiveCfg = Debug|Win32
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Debug|x86.Build.0 = Debug|Win32
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Release|x64.ActiveCfg = Release|x64
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Release|x64.Build.0 = Release|x64
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Release|x86.ActiveCfg = Release|Win32
+ {3CECADE6-3E15-4852-BD24-65BFE5D3A3AA}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {EC527F13-2A1D-4796-AF96-DD5DD02A70F9}
+ EndGlobalSection
+EndGlobal
diff --git a/CST116-Lab2-PseudoCode-Preston.txt b/CST116-Lab2-PseudoCode-Preston.txt
new file mode 100644
index 0000000..e8b7e6b
--- /dev/null
+++ b/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