diff options
Diffstat (limited to 'CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp')
| -rw-r--r-- | CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp b/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp index 497e2f8..f572c79 100644 --- a/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp +++ b/CST116-Ch6-Debugging/CST116-Ch6-Debugging.cpp @@ -51,10 +51,15 @@ int main() // Breakpoint 1
// Put a breakpoint on the following line
- celcius = 5 / 9 * fahrenheit - 32;
+ celcius = 5.0 / 9.0 * (fahrenheit - 32);
cout << fahrenheit << " degrees F = "
<< celcius << " degrees C" << endl;
return 0;
}
+// To convert from Farenheit to celsius is 5/9 * ( F - 32). Part one has you test the code and you will discover that
+// it says farenheit of 212 = 0 celcius. doing some arithmatic you find out 212 F = 100 C. It is due to an integer error
+// in the fomula celcius = 5/9 * (fahrenheit - 32). Fix this by adding .0 to each number.
+//Part 2 Has you correct the code to celcius = 5.0 / 9.0 * (fahrenheit - 32). This gives you the proper answer of 100 degrees Celcius.
+// Hope this helps. LLoyd C
\ No newline at end of file |