diff options
| author | Andrei Florea <[email protected]> | 2022-10-05 16:35:28 -0700 |
|---|---|---|
| committer | Andrei Florea <[email protected]> | 2022-10-05 16:35:28 -0700 |
| commit | 21d6253b04632310fa9b4b89cabf06787303258f (patch) | |
| tree | 17ffe8f59a59ea3cb167a4095adbae26282a20f6 | |
| parent | Adding .gitignore file for my IDE 'CLion' (diff) | |
| download | cst116-lab0-debugging-florea-21d6253b04632310fa9b4b89cabf06787303258f.tar.xz cst116-lab0-debugging-florea-21d6253b04632310fa9b4b89cabf06787303258f.zip | |
Completed Debugging assignment
| -rw-r--r-- | .idea/.name | 1 | ||||
| -rw-r--r-- | .idea/cst116-lab0-debugging-florea.iml | 8 | ||||
| -rw-r--r-- | .idea/misc.xml | 4 | ||||
| -rw-r--r-- | Ch 5 Debugging Project/Ch 5 Debugging Project.cpp | 17 |
4 files changed, 22 insertions, 8 deletions
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 @@ <?xml version="1.0" encoding="UTF-8"?> -<module type="CPP_MODULE" version="4"> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$" /> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module>
\ No newline at end of file +<module classpath="CMake" type="CPP_MODULE" version="4" />
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" /> +</project>
\ 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;
|