From 21d6253b04632310fa9b4b89cabf06787303258f Mon Sep 17 00:00:00 2001 From: Andrei Florea Date: Wed, 5 Oct 2022 16:35:28 -0700 Subject: Completed Debugging assignment --- .idea/.name | 1 + .idea/cst116-lab0-debugging-florea.iml | 8 +------- .idea/misc.xml | 4 ++++ Ch 5 Debugging Project/Ch 5 Debugging Project.cpp | 17 ++++++++++++++++- 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/misc.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..48f51ed --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +cst116_lab0_debugging_florea \ No newline at end of file diff --git a/.idea/cst116-lab0-debugging-florea.iml b/.idea/cst116-lab0-debugging-florea.iml index bc2cd87..f08604b 100644 --- a/.idea/cst116-lab0-debugging-florea.iml +++ b/.idea/cst116-lab0-debugging-florea.iml @@ -1,8 +1,2 @@ - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file 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; -- cgit v1.2.3