aboutsummaryrefslogtreecommitdiff
path: root/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp
diff options
context:
space:
mode:
authorAndrei Florea <[email protected]>2022-10-05 16:35:28 -0700
committerAndrei Florea <[email protected]>2022-10-05 16:35:28 -0700
commit21d6253b04632310fa9b4b89cabf06787303258f (patch)
tree17ffe8f59a59ea3cb167a4095adbae26282a20f6 /Ch 5 Debugging Project/Ch 5 Debugging Project.cpp
parentAdding .gitignore file for my IDE 'CLion' (diff)
downloadcst116-lab0-debugging-florea-21d6253b04632310fa9b4b89cabf06787303258f.tar.xz
cst116-lab0-debugging-florea-21d6253b04632310fa9b4b89cabf06787303258f.zip
Completed Debugging assignment
Diffstat (limited to 'Ch 5 Debugging Project/Ch 5 Debugging Project.cpp')
-rw-r--r--Ch 5 Debugging Project/Ch 5 Debugging Project.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp b/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp
index 56716e7..8e8b66c 100644
--- a/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp
+++ b/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp
@@ -39,11 +39,24 @@
* 5) Notice that the current line of execution is now at the
* calculation.
* 6) Look at your watch. What is the value of money?
+ *
+ * The value of money is 123.449997
+ *
* 7) Hover your mouse pointer over raise. What is its value?
+ *
+ * The value of raise is 0.100000001
+ *
* 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.
+ *
+ * What happened to the money is that it was multiplying the raise which was set as input of a decimal,
+ * for example, raise was .1, but when you multiply that by the amount of money, the answer you receive
+ * is supposed to be the additional money to the raise. To fix this, if raise is always going to be a decimal
+ * below 1, you can add write ( raise + 1 ), which will add 1 to raise before multiplying it. So instead of
+ * multiplying 0.1 with the amount of money, you are multiplying 1.1 with the amount of money which is the correct
+ * amount.
*
* Debugging Exercise 3
*
@@ -55,6 +68,8 @@
* you end up with more money than before the raise.
* 4) Stop debugging. Now run the entire program by choosing the menu
* option Start Without Debugging.
+ *
+ * Done, now when I input .1 (same as before), instead of the money being lower, it is now higher.
*
********************************************************************/
@@ -77,7 +92,7 @@ int main()
cout << "Enter percent raise: ";
cin >> raise;
- money = money * raise;
+ money = money * ( raise + 1 );
cout << "After your raise you have $";
cout << money << endl;