From a4d3d1bbc10f1aecf2fb5cba6f2a82dd23fde5ab Mon Sep 17 00:00:00 2001 From: EdwardFine Date: Tue, 8 Nov 2022 23:49:55 -0800 Subject: 1 --- BlankConsoleLab/BlankConsoleLab.cpp | 16 ------ BlankConsoleLab/BlankConsoleLab.vcxproj | 10 ++-- BlankConsoleLab/BlankConsoleLab.vcxproj.filters | 2 +- .../CST116-Lab2-Edward-Fine-PseudoCode.txt | 5 ++ BlankConsoleLab/CST116-Lab2-Edward-Fine.cpp | 64 ++++++++++++++++++++++ 5 files changed, 75 insertions(+), 22 deletions(-) delete mode 100644 BlankConsoleLab/BlankConsoleLab.cpp create mode 100644 BlankConsoleLab/CST116-Lab2-Edward-Fine-PseudoCode.txt create mode 100644 BlankConsoleLab/CST116-Lab2-Edward-Fine.cpp 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..d15e62e 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj @@ -29,26 +29,26 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode @@ -139,7 +139,7 @@ - + diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters index aca1dd9..b10efac 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files diff --git a/BlankConsoleLab/CST116-Lab2-Edward-Fine-PseudoCode.txt b/BlankConsoleLab/CST116-Lab2-Edward-Fine-PseudoCode.txt new file mode 100644 index 0000000..7f6fd62 --- /dev/null +++ b/BlankConsoleLab/CST116-Lab2-Edward-Fine-PseudoCode.txt @@ -0,0 +1,5 @@ +Figure out if the user is inputting in celcius or fahrenheit. +prompt the user to input their respected temperature. If it was inputted into celcius, convert to fahrenheit. +Ask the user for the wind speed. +Using the two values given, calulate the wind chill. +Display the windchill to the user. \ No newline at end of file diff --git a/BlankConsoleLab/CST116-Lab2-Edward-Fine.cpp b/BlankConsoleLab/CST116-Lab2-Edward-Fine.cpp new file mode 100644 index 0000000..dd14e20 --- /dev/null +++ b/BlankConsoleLab/CST116-Lab2-Edward-Fine.cpp @@ -0,0 +1,64 @@ +// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include +#include + +using namespace std; + +using std::cout; +using std::cin; +using std::endl; +void convertToF(int *c); +float getChill(int speed, int chill); + +int main() +{ + char temp = 'f'; + int degree=122; + int windSpeed = 232; + float windChill; + cout << "Are you inputting temperature in celcius or fahrenheit? C/f? "; + cin >> temp; + if (temp == 'c' || temp == 'C') { + while (degree < -62 || degree > 49.5) { + cout << "What is your temperature in celcius from -62 to 49.5 degrees? "; + cin >> degree; + } + convertToF(°ree); + } + else if (temp == 'f' || temp == 'F') { + while (degree < -80 || degree > 121) { + cout << "What is your temperature in fahrenheit from -80 to 121 degrees? "; + cin >> degree; + } + } + while (windSpeed < 0 || windSpeed > 231) { + cout << "Please input the wind speed in MPH: "; + cin >> windSpeed; + } + windChill = getChill(degree, windSpeed); + cout << "The windchill for " << degree << " degrees Fahrenheit and " << windSpeed << " mph winds is " << windChill; + + +} +//this convertToF function serves to convert any celcius input to Fahrenheit by taking the input of the degree given and +//performing an algebraic function to convert it. It returns no value because it overwrites the original variable's value. +void convertToF(int *c) { + cout << "Converting Celcius to Farhrenheit..."<< endl; + *c = 9 / 5 * *c + 32; + return; +} +//This getChill function serves to calculate the windchill. I had seperated them all out into segments because I was having +//trouble calulating it right and though it was an order of operations issue, but it was a float issue. This has the inputs of +//the degree temp taken from the user and the wind speed given from the user and returns the calculated value. +float getChill(int temp, int speed) { + cout << "Calculating windchill..."<< endl; + float tempSpeed = pow(speed, .16); + float temp1 = 35.74 + (.6215 * temp); + float temp2 = 35.75 * tempSpeed; + float temp3 = .4275 * temp * tempSpeed; + float chill = temp1 - temp2 + temp3; + return chill; +} + -- cgit v1.2.3