From 5293aea6a14e89a2efb6d28f1a2d43e693ab8ca3 Mon Sep 17 00:00:00 2001 From: Trevor Bouchillon Date: Sun, 2 Oct 2022 12:20:44 -0700 Subject: Debug 2 Complete --- Ch 5 Debugging Project/Ch 5 Debugging Project.cpp | 51 ++++++++++++++++------- Ch 5 Debugging Project/Output-Debug.txt | 14 +++++++ 2 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 Ch 5 Debugging Project/Output-Debug.txt (limited to 'Ch 5 Debugging Project') diff --git a/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp b/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp index f1fc246..b67c169 100644 --- a/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp +++ b/Ch 5 Debugging Project/Ch 5 Debugging Project.cpp @@ -16,6 +16,10 @@ * 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? +* ******************************************************************************************************************************************* + After the first cout statement we are at the line of code were the variable money is displayed in the console window. + Money appears to be a float type integer with a value of 123.449997 It shows up in the watch section of the code. + ******************************************************************************************************************************************* * 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 +29,9 @@ * line. * 10) Step over the next cout statement. Now look at the console * window. What was printed? +* ******************************************************************************************************************************************* + The value shown in the watch was printed rounded to 2 decimal points. + ******************************************************************************************************************************************* * 11) Select Stop Debugging either from the Debug menu or from your * toolbar. * @@ -38,12 +45,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.449997 +* ******************************************************************************************************************************************** * 7) Hover your mouse pointer over raise. What is its value? +* ******************************************************************************************************************************************** +* 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. -* +* ******************************************************************************************************************************************** +* Our money was multiplied by 0.1 this reducing the overall amount we have. +* ******************************************************************************************************************************************** * Debugging Exercise 3 * * 1) Choose Disable All Breakpoints from the Debug menu. @@ -59,6 +74,7 @@ #include #include + using std::cout; using std::cin; using std::endl; @@ -70,23 +86,28 @@ int main() cout << "You have $"; cout << money << endl; - /* ******************************************************************************************************************************************* - After the first cout statement we are at the line of code were the variable money is displayed in the console window. - Money appears to be a float type integer with a value of 123.449997 It shows up in the watch section of the code. - ****************************************************************************************************************************************** - */ + // Breakpoint 1 // Put a breakpoint on the following line - cout << "Enter percent raise: "; - /* ******************************************************************************************************************************************* - The value shown in the watch was printed rounded to 2 decimal points. - *******************************************************************************************************************************************/ + + while (true) { + cout << "Enter percent raise: "; cin >> raise; + if (raise >= 1) + { + cout << "Please enter a value between 0 and 1"; + } + else if (raise <= 0) { + cout << "Please enter a value between 0 and 1"; + } + else { + raise = raise + 1; + money = money * raise; - money = money * raise; - - cout << "After your raise you have $"; - cout << money << endl; - + cout << "After your raise you have $"; + cout << money << endl; + return 0; + } + } return 0; } \ No newline at end of file diff --git a/Ch 5 Debugging Project/Output-Debug.txt b/Ch 5 Debugging Project/Output-Debug.txt new file mode 100644 index 0000000..b591fb2 --- /dev/null +++ b/Ch 5 Debugging Project/Output-Debug.txt @@ -0,0 +1,14 @@ +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Users\lacro\source\repos\cst116-lab0-debugging-DaBoochillin\Ch 5 Debugging Project\x64\Debug\Ch 5 Debugging Project.exe'. Symbols loaded. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_1d.dll'. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. +The thread 0x1ac4 has exited with code 0 (0x0). +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. +'Ch 5 Debugging Project.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. +The thread 0x5090 has exited with code 0 (0x0). +The thread 0x25a4 has exited with code 0 (0x0). +The program '[11120] Ch 5 Debugging Project.exe' has exited with code 0 (0x0). -- cgit v1.2.3