aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-01-27 17:02:18 -0800
committerConnor McDowell <[email protected]>2024-01-27 17:02:18 -0800
commita21264f2fe90dbc83e1b8b8fba0f977b11c37172 (patch)
treeb24c5c067d8e04a8ed73d2c9fe0574cfdcf3aa86
parentifdef verbose added to F selection (diff)
downloadhomework-2-connormcdowell275-a21264f2fe90dbc83e1b8b8fba0f977b11c37172.tar.xz
homework-2-connormcdowell275-a21264f2fe90dbc83e1b8b8fba0f977b11c37172.zip
F to C completed with statements (identical to C to F, number ranges changed) including ifdef verbose.
-rw-r--r--homework2/homework2.cpp39
1 files changed, 38 insertions, 1 deletions
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