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 --- Ch 5 Debugging Project/Ch 5 Debugging Project.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Ch 5 Debugging Project/Ch 5 Debugging Project.cpp') 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