From 48de5e495fb2076fa6a7fc7db4ba0d8370fcd391 Mon Sep 17 00:00:00 2001 From: Joseph Williams Date: Wed, 9 Nov 2022 11:41:49 -0800 Subject: holy crap everything worked on the first try. that has actually never happened before. --- BlankConsoleLab/BlankConsoleLab.vcxproj | 1 + BlankConsoleLab/BlankConsoleLab.vcxproj.filters | 3 +++ BlankConsoleLab/CST116_Lab2_Williams.cpp | 13 ++++++++----- BlankConsoleLab/CST116_Lab2_Williams_Run.txt | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 BlankConsoleLab/CST116_Lab2_Williams_Run.txt diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj index 6ee166d..58664f6 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj @@ -143,6 +143,7 @@ + diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters index ca64071..21212f6 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters @@ -23,5 +23,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/BlankConsoleLab/CST116_Lab2_Williams.cpp b/BlankConsoleLab/CST116_Lab2_Williams.cpp index e622b07..48689e4 100644 --- a/BlankConsoleLab/CST116_Lab2_Williams.cpp +++ b/BlankConsoleLab/CST116_Lab2_Williams.cpp @@ -104,7 +104,7 @@ bool isNumber(string str) { // 0: The user entered the temperature in F // 1: The user entered the temperature in C float getTemp(int& unit) { - vector > asktext = {make_tuple("Please enter the current temperature followed by its unit (", 15, 0), make_tuple("[F]ahrenheit", 11, 0), make_tuple(" or ", 15, 0), make_tuple("[C]elcius", 11, 0), make_tuple("): ", 15, 0)}; + vector > asktext = {make_tuple("Please enter the current temperature followed by its unit (", 15, 0), make_tuple("Fahrenheit", 11, 0), make_tuple(" or ", 15, 0), make_tuple("Celcius", 11, 0), make_tuple("): ", 15, 0)}; float temp; while (true) { @@ -271,14 +271,17 @@ int main() kphWind = wind; } - // Calculate the wind chill. The wind chill calculator uses Imperial units and I just convert it to Celcius. + // Calculate the wind chill. The wind chill calculator uses Imperial units, and I just convert it to Celcius. fChill = windChill(fTemp, mphWind); cChill = dftodc(fChill); // Print all the output, using needlessly complicated functions that I'm too stubborn to refine. - vector > tempOut = { make_tuple("The temperature is ", 15, 0), make_tuple(to_string(fTemp) + " degrees Fahrenheit", 11, 0), make_tuple(", or ", 15, 0), make_tuple(to_string(cTemp) + " degrees Celcius", 11, 0), make_tuple(".", 15, 0), }; - vector > windOut = { make_tuple("The wind speed is ", 15, 0), make_tuple(to_string(mphWind) + " miles per hour", 11, 0), make_tuple(", or ", 15, 0), make_tuple(to_string(kphWind) + " kilometers per hour", 11, 0), make_tuple(".", 15, 0), }; - vector > chillOut = { make_tuple("The wind chill is ", 15, 0), make_tuple(to_string(fChill) + " degrees Fahrenheit", 11, 0), make_tuple(", or ", 15, 0), make_tuple(to_string(cChill) + " degrees Celcius", 15, 0), make_tuple(".", 15, 0), }; + vector > tempOut = { make_tuple("The temperature is ", 15, 0), make_tuple(to_string(fTemp) + " degrees Fahrenheit", 11, 0), make_tuple(", or ", 15, 0), make_tuple(to_string(cTemp) + " degrees Celcius", 11, 0), make_tuple(".", 15, 1), }; + vector > windOut = { make_tuple("The wind speed is ", 15, 0), make_tuple(to_string(mphWind) + " miles per hour", 11, 0), make_tuple(", or ", 15, 0), make_tuple(to_string(kphWind) + " kilometers per hour", 11, 0), make_tuple(".", 15, 1), }; + vector > chillOut = { make_tuple("The wind chill is ", 15, 0), make_tuple(to_string(fChill) + " degrees Fahrenheit", 11, 0), make_tuple(", or ", 15, 0), make_tuple(to_string(cChill) + " degrees Celcius", 11, 0), make_tuple(".", 15, 1), }; + multiColorPrint(tempOut); + multiColorPrint(windOut); + multiColorPrint(chillOut); return 0; } diff --git a/BlankConsoleLab/CST116_Lab2_Williams_Run.txt b/BlankConsoleLab/CST116_Lab2_Williams_Run.txt new file mode 100644 index 0000000..fea6830 --- /dev/null +++ b/BlankConsoleLab/CST116_Lab2_Williams_Run.txt @@ -0,0 +1,15 @@ +Please enter the current temperature followed by its unit (Fahrenheit or Celcius): thirty-four degrees celcius +Oh no! Something went wrong. Make sure you enter a number and a unit. +Please enter the current temperature followed by its unit (Fahrenheit or Celcius): 93 C +Oh no! Something went wrong. Make sure you enter a temperature between -80 and 121 Fahrenheit (-62 and 49.5 Celcius). +Please enter the current temperature followed by its unit (Fahrenheit or Celcius): 121.1 fahrenheit +Oh no! Something went wrong. Make sure you enter a temperature between -80 and 121 Fahrenheit (-62 and 49.5 Celcius). +Please enter the current temperature followed by its unit (Fahrenheit or Celcius): -54 celcius +Please enter the current wind speed followed by its unit (miles per hour or kilometers per hour): 1123 miles per hour +Oh no! Something went wrong. Make sure you enter a wind speed between 0 and 231 miles per hour (0 and 370 kilometers per hour). +Please enter the current wind speed followed by its unit (miles per hour or kilometers per hour): 2543 kph +Oh no! Something went wrong. Make sure you enter a wind speed between 0 and 231 miles per hour (0 and 370 kilometers per hour). +Please enter the current wind speed followed by its unit (miles per hour or kilometers per hour): 93 kilometers per hour +The temperature is -65.199997 degrees Fahrenheit, or -54.000000 degrees Celcius. +The wind speed is 57.799877 miles per hour, or 93.000000 kilometers per hour. +The wind chill is -126.546791 degrees Fahrenheit, or -88.081543 degrees Celcius. \ No newline at end of file -- cgit v1.2.3