aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch5-Debugging/CST116-Ch5-Debugging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CST116-Ch5-Debugging/CST116-Ch5-Debugging.cpp')
-rw-r--r--CST116-Ch5-Debugging/CST116-Ch5-Debugging.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/CST116-Ch5-Debugging/CST116-Ch5-Debugging.cpp b/CST116-Ch5-Debugging/CST116-Ch5-Debugging.cpp
index 851932d..8e8bfd7 100644
--- a/CST116-Ch5-Debugging/CST116-Ch5-Debugging.cpp
+++ b/CST116-Ch5-Debugging/CST116-Ch5-Debugging.cpp
@@ -16,6 +16,9 @@
* the current line being that cout statement, Step Into again.
* 6) What happened? Where are we now? What is all of this nasty
* looking code?
+*
+* I'm gonna be honest here, I have no idea what the "nasty looking code" you're talking about is, unless its the lines about "the thread [number] has exited with code [number]", which doesn't look all that nasty to me.
+*
* 7) Remember, stepping into a predefined routine takes you to the
* code for that routine. If the debugger can't find the code it
* will show the assembly code for that routine.
@@ -25,6 +28,9 @@
* line.
* 10) Step over the next cout statement. Now look at the console
* window. What was printed?
+*
+* Assuming we're both looking in the same place, "The thread 0x367c has exited with code 0 (0x0).", which doesn't look all that nasty to me. I'm no expert, but "code 0" definitely feels too short for an error code.
+*
* 11) Select Stop Debugging either from the Debug menu or from your
* toolbar.
*
@@ -38,11 +44,20 @@
* 5) Notice that the current line of execution is now at the
* calculation.
* 6) Look at your watch. What is the value of money?
+*
+* 123.45
+*
* 7) Hover your mouse pointer over raise. What is its value?
+*
+* 0.1
+*
* 8) Step over the calculation. Notice the watch on money is now
* red. This designates that the variable just changed its value.
* 9) What happened to our money? I thought a raise was supposed
* to increase our money? Stop debugging and fix the calculation.
+*
+* Inputting 0.1 for raise causes it to return 10% of money, instead of money + 10%. Just add 1 to raise before calculating. Also, "money *= (1 + raise)" is significantly more readable than "money = money (1 + raise)".
+*
*
* Debugging Exercise 3
*
@@ -73,10 +88,11 @@ int main()
// Breakpoint 1
// Put a breakpoint on the following line
+
cout << "Enter percent raise: ";
cin >> raise;
- money = money * raise;
+ money *= (raise + 1);
cout << "After your raise you have $";
cout << money << endl;