From a21264f2fe90dbc83e1b8b8fba0f977b11c37172 Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Sat, 27 Jan 2024 17:02:18 -0800 Subject: F to C completed with statements (identical to C to F, number ranges changed) including ifdef verbose. --- homework2/homework2.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/homework2/homework2.cpp b/homework2/homework2.cpp index 7486f10..4ade128 100644 --- a/homework2/homework2.cpp +++ b/homework2/homework2.cpp @@ -26,7 +26,44 @@ int main() cin >> fah; - float FtoC(float fah); + float num = (fah - 32) * (5 / 9); + + if (-8 < num && num < 5) + { + std::cout << "The temperature: " << num << " fahrenheit, is cold enough that water freezes! brrr!" << std::endl; + } + + if (6 < num && num < 15) + { + std::cout << "The temperature: " << num << " fahrenheit, is quite chilly! bring a sweater" << std::endl; + } + + if (15 < num && num < 24) + { + std::cout << "The temperature: " << num << " fahrenheit, is around room temperature and quite comfortable" << std::endl; + } + + if (25 < num && num < 30) + { + std::cout << "The temperature: " << num << " fahrenheit, is pretty warm! drink plenty of water and stay in the shade when you can." << std::endl; + } + + if (31 < num && num < 39) + { + std::cout << "The temperature: " << num << " fahrenheit, is very hot, wear sunscreen and hydrate often if going out." << std::endl; + } + + if (num > 40) + { + std::cout << "The temperature: " << num << " fahrenheit, do not even think about leaving the house." << std::endl; + } + #ifdef VERBOSE + { + std::cout << fah << " F to C" << std::endl; + std::cout << "C = (" << fah << " - 32) * (5/9)" << std::endl; + std::cout << "C = " << num << " " << std::endl; + } + #endif VERBOSE } // DONE -- cgit v1.2.3