diff options
| author | Lloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5> | 2022-11-09 19:41:35 -0800 |
|---|---|---|
| committer | Lloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5> | 2022-11-09 19:41:35 -0800 |
| commit | 530ccd3f872d749e5c6757da99cd5f0dd701cd3e (patch) | |
| tree | 17ad439d7c74c9a6d0277abfa391c586562baa7f /BlankConsoleLab | |
| parent | Setting up GitHub Classroom Feedback (diff) | |
| download | cst116-lab2-19-ruin-530ccd3f872d749e5c6757da99cd5f0dd701cd3e.tar.xz cst116-lab2-19-ruin-530ccd3f872d749e5c6757da99cd5f0dd701cd3e.zip | |
Diffstat (limited to 'BlankConsoleLab')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 16 | ||||
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.vcxproj | 11 | ||||
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.vcxproj.filters | 2 | ||||
| -rw-r--r-- | BlankConsoleLab/CST116-Lab2-Cold-Crawford.cpp | 86 |
4 files changed, 93 insertions, 22 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp deleted file mode 100644 index ed5f807..0000000 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include <iostream> - -using namespace std; - -using std::cout; -using std::cin; -using std::endl; - -int main() -{ - cout << "Hello World!\n"; -} - diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj index db2e734..cd52261 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj @@ -24,31 +24,32 @@ <ProjectGuid>{3cecade6-3e15-4852-bd24-65bfe5d3a3aa}</ProjectGuid> <RootNamespace>BlankConsoleLab</RootNamespace> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + <ProjectName>CST116Lab2ColdCrawford</ProjectName> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <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> @@ -139,7 +140,7 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="BlankConsoleLab.cpp" /> + <ClCompile Include="CST116-Lab2-Cold-Crawford.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters index aca1dd9..a2caee8 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters @@ -15,7 +15,7 @@ </Filter> </ItemGroup> <ItemGroup> - <ClCompile Include="BlankConsoleLab.cpp"> + <ClCompile Include="CST116-Lab2-Cold-Crawford.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> diff --git a/BlankConsoleLab/CST116-Lab2-Cold-Crawford.cpp b/BlankConsoleLab/CST116-Lab2-Cold-Crawford.cpp new file mode 100644 index 0000000..9db8518 --- /dev/null +++ b/BlankConsoleLab/CST116-Lab2-Cold-Crawford.cpp @@ -0,0 +1,86 @@ +// CST 116, Lab2: Baby it's cold outside, Lloyd Crawford. This file contains the 'main' function. Program execution begins and ends there. +// + + +#include <iostream> +#include <cmath> +#include <iomanip> +using namespace std; + + + +//Part 2 + +float c_2_f(float c) +{ + return (9.0 / 5.0) * (c + 32); +} + +void f_2_c(float f, float& c) +{ + c = (5.0 / 9.0) * (f - 32); +} + +float GetWindChill(float temp, float windSpeed) +{ + + // Calculates the wind chill in fahrenheit, and can convert it to celsius using a previous function + + float windChill; + + windChill = 35.74 + (0.6215 * temp) + (pow(windSpeed, 0.16) * ((0.4275 * temp) - 35.75)); + + return windChill; // Returns the wind chill based on what the user entered before the function has been called. Only outputs as fahrenheit. + +} + +int main() +{ + //Part 1 + char convert_choice = '0'; + float celcius = -200; // force to be out of range -62 to 49.5 + float fahrenheit = -200; // force to be out of range -80 & 121 + float windChill = 0; + float windSpeed = -1; // force to be out of range 0 and 231 + + + while (convert_choice != 'C' && convert_choice != 'F') // force to be C or F + { + cout << "Enter C for Celsius to Fahrenheit or F for Fahrenheit to Celsius: "; + cin >> convert_choice; + } + if (convert_choice == 'C') + { + while (celcius < -62 || celcius > 49.5) // force range here -62 to 49.5 + { + cout << "Enter a number for degree in Celsius from -62 to 49.5: "; + cin >> celcius; + } + fahrenheit = c_2_f(celcius); + } + else + { + while (fahrenheit < -80 || fahrenheit > 121) // forces fahrenheit to be between -80 & 121 + { + cout << "Enter a number for degree in fahrenheit from -80 to 121: "; + cin >> fahrenheit; + } + f_2_c(fahrenheit, celcius); // call conversion function with pbv and pbr parameters + } + + while (windSpeed < 0 || windSpeed > 231) { + + cout << "Please enter a number for the wind speed from 0 to 231 mph.\n"; + cin >> windSpeed; + + } + + + windChill = GetWindChill(fahrenheit, windSpeed); + + cout << fixed << setprecision(2) << left; + cout << setw(20) << "CELSIUS" << setw(20) << "FAHRENHEIT" << setw(20) << "WIND SPEED" << setw(20) << "WIND CHILL" << endl; + cout << setw(20) << celcius << setw(20) << fahrenheit << setw(20) << windSpeed << setw(20) << windChill << endl; + cout << "Here is your data. Bundle up!" << endl; + return 0; +}
\ No newline at end of file |