From 530ccd3f872d749e5c6757da99cd5f0dd701cd3e Mon Sep 17 00:00:00 2001 From: Lloyd Crawford Date: Wed, 9 Nov 2022 19:41:35 -0800 Subject: Here is my completed Lab 2 --- BlankConsoleLab.sln | 31 --------- BlankConsoleLab/BlankConsoleLab.cpp | 16 ----- BlankConsoleLab/BlankConsoleLab.vcxproj | 11 ++-- BlankConsoleLab/BlankConsoleLab.vcxproj.filters | 2 +- BlankConsoleLab/CST116-Lab2-Cold-Crawford.cpp | 86 +++++++++++++++++++++++++ CST116-Lab2Cold-Crawford.sln | 31 +++++++++ Cst116-Lab2-Output-Crawford.txt | 27 ++++++++ Cst116-Lab2-Pseudocode-Crawford.txt | 84 ++++++++++++++++++++++++ 8 files changed, 235 insertions(+), 53 deletions(-) delete mode 100644 BlankConsoleLab.sln delete mode 100644 BlankConsoleLab/BlankConsoleLab.cpp create mode 100644 BlankConsoleLab/CST116-Lab2-Cold-Crawford.cpp create mode 100644 CST116-Lab2Cold-Crawford.sln create mode 100644 Cst116-Lab2-Output-Crawford.txt create mode 100644 Cst116-Lab2-Pseudocode-Crawford.txt diff --git a/BlankConsoleLab.sln b/BlankConsoleLab.sln deleted file mode 100644 index 8e981c8..0000000 --- a/BlankConsoleLab.sln +++ /dev/null @@ -1,31 +0,0 @@ - -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/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 - -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 @@ {3cecade6-3e15-4852-bd24-65bfe5d3a3aa} BlankConsoleLab 10.0 + CST116Lab2ColdCrawford Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode @@ -139,7 +140,7 @@ - + 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 @@ - + Source Files 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 +#include +#include +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 diff --git a/CST116-Lab2Cold-Crawford.sln b/CST116-Lab2Cold-Crawford.sln new file mode 100644 index 0000000..553b6b7 --- /dev/null +++ b/CST116-Lab2Cold-Crawford.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32922.545 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CST116Lab2ColdCrawford", "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-Output-Crawford.txt b/Cst116-Lab2-Output-Crawford.txt new file mode 100644 index 0000000..e0fe0d9 --- /dev/null +++ b/Cst116-Lab2-Output-Crawford.txt @@ -0,0 +1,27 @@ +Cst 116 - lab 2 Output + +Output 1: +Enter C for Celsius to Fahrenheit or F for Fahrenheit to Celsius: C +Enter a number for degree in Celsius from -62 to 49.5: 34 +Please enter a number for the wind speed from 0 to 231 mph. +200 +CELSIUS FAHRENHEIT WIND SPEED WIND CHILL +34.00 118.80 200.00 144.68 +Here is your data. Bundle up! + +C:\Users\Lloyd Crawford\source\repos\cst116-lab2-19-Ruin\x64\Debug\CST116Lab2ColdCrawford.exe (process 5932) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . + +Output 2: +Enter C for Celsius to Fahrenheit or F for Fahrenheit to Celsius: F +Enter a number for degree in fahrenheit from -80 to 121: 100 +Please enter a number for the wind speed from 0 to 231 mph. +175 +CELSIUS FAHRENHEIT WIND SPEED WIND CHILL +37.78 100.00 175.00 113.88 +Here is your data. Bundle up! + +C:\Users\Lloyd Crawford\source\repos\cst116-lab2-19-Ruin\x64\Debug\CST116Lab2ColdCrawford.exe (process 11580) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . \ No newline at end of file diff --git a/Cst116-Lab2-Pseudocode-Crawford.txt b/Cst116-Lab2-Pseudocode-Crawford.txt new file mode 100644 index 0000000..599a3ef --- /dev/null +++ b/Cst116-Lab2-Pseudocode-Crawford.txt @@ -0,0 +1,84 @@ +CST116 Lab 2 Pseudo code + + + +Create functions to define the temperature in celcius or fahrenheit. +float functions +Part 2 while it starts first it is so that it functions cohesively with part 1. + + +//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 -- cgit v1.2.3