aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Hill <[email protected]>2022-09-29 16:13:49 -0700
committerAaron Hill <[email protected]>2022-09-29 16:13:49 -0700
commita60d2d3415b120b581b421c194782b4361b9b6b1 (patch)
tree3d0084800a2dddf50032be13631a6d2e7c25c520
parentFinished (diff)
downloadcst116-ch6-debugging-hill-a60d2d3415b120b581b421c194782b4361b9b6b1.tar.xz
cst116-ch6-debugging-hill-a60d2d3415b120b581b421c194782b4361b9b6b1.zip
Finished
-rw-r--r--CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp b/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp
index 497e2f8..386454a 100644
--- a/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp
+++ b/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp
@@ -13,6 +13,9 @@
* 5) Verify that the value you entered is stored correctly.
* 6) Step over the conversion calculation. What is the value
* in Celsius? Is that the correct value? No.
+*
+* -32 degrees
+*
* 7) Remember your order of precedence. Put parentheses around
* Fahrenheit - 32. This needs to be done before the multiplication.
* 8) Stop debugging and recompile.
@@ -24,6 +27,9 @@
* 3) Verify that the value you entered is stored correctly.
* 4) Step over the conversion calculation. What is the value
* in Celsius? Is that the correct value? No.
+*
+* 0 degrees
+*
* 5) Look at the division. This is integer division. Therefore,
* 5 / 9 = 0. This is not the result we are looking for.
* 6) Modify the calculation so that it does floating point division.
@@ -51,7 +57,7 @@ int main()
// Breakpoint 1
// Put a breakpoint on the following line
- celcius = 5 / 9 * fahrenheit - 32;
+ celcius = 5.0F / 9.0F * (fahrenheit - 32);
cout << fahrenheit << " degrees F = "
<< celcius << " degrees C" << endl;