aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch7-Debugging
diff options
context:
space:
mode:
authorLloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5>2022-10-19 14:38:17 -0700
committerLloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5>2022-10-19 14:38:17 -0700
commitd31ed47de1018782837ca1b7674fb518b4d11921 (patch)
treeb194f0a4c97f6d679a5ae5ce45a4319d9a72b6c3 /CST116-Ch7-Debugging
parentHere is my completed CH7 debug (diff)
downloadcst116-ch7-debugging-19-ruin-main.tar.xz
cst116-ch7-debugging-19-ruin-main.zip
Here is my completed CH7 Debugging assignment!!!HEADmain
Diffstat (limited to 'CST116-Ch7-Debugging')
-rw-r--r--CST116-Ch7-Debugging/CST116-CH 7 Debugging-Results-Crawford.txt6
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7 Debugging-PSeudo code-Crawford.txt (renamed from CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp)156
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7-Debugging-Crawford.cpp83
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj3
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters2
5 files changed, 175 insertions, 75 deletions
diff --git a/CST116-Ch7-Debugging/CST116-CH 7 Debugging-Results-Crawford.txt b/CST116-Ch7-Debugging/CST116-CH 7 Debugging-Results-Crawford.txt
new file mode 100644
index 0000000..a2f4b96
--- /dev/null
+++ b/CST116-Ch7-Debugging/CST116-CH 7 Debugging-Results-Crawford.txt
@@ -0,0 +1,6 @@
+Enter your age: 28
+Adult
+
+C:\Users\Lloyd Crawford\source\repos\cst116-ch7-debugging-19-Ruin\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging-Crawford.exe (process 25664) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7 Debugging-PSeudo code-Crawford.txt
index f64adfe..da3b7f6 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
+++ b/CST116-Ch7-Debugging/CST116-Ch7 Debugging-PSeudo code-Crawford.txt
@@ -1,73 +1,83 @@
-/********************************************************************
-* File: CST116-Ch7-Debugging.cpp
-*
-* General Instructions: Complete each step before proceeding to the
-* next.
-*
-* Debugging Exercise 1
-*
-* 1) Insert a breakpoint on the lines indicated in the code.
-* 2) Run to Breakpoint 1.
-* 3) When prompted, enter your age.
-* 4) When the execution stops, add a watch on age and verify that
-* the value in age is what you typed in.
-* 5) Step over the if statement.
-* 6) Why did the value in age change?
-* 7) Fix the problem and repeat Steps 2 � 5 to verify the
-* problem was corrected.
-* 8) Stop debugging.
-*
-* Debugging Exercise 2
-*
-* 1) Run to Breakpoint 1.
-* 2) When prompted, enter the value 25 for your age.
-* 3) Step over the if statement. Execution of the program should
-* continue on the else if statement.
-* 4) Verify that 25 is still stored in age.
-* 5) Step over the else if.
-* 6) Why is the program going to print "Teenager" for an age of 25?
-* 7) Fix the problem and repeat Steps 1 � 5 to verify the
-* problem was corrected.
-* 8) Stop debugging.
-* 9) Remove Breakpoint1.
-*
-* Debugging Exercise 3
-*
-* 1) Run the program without debugging.
-* 2) When prompted, enter the value of 10 for your age.
-* 3) Why does the program print both "Child" and "Adult"?
-* 4) Re-run the program this time with debugging and run to
-* Breakpoint 2.
-* 5) Why is the action with the else executing?
-* 6) Fix the problem and re-run to verify the problem was corrected.
-********************************************************************/
-
-#include <iostream>
-using std::cout;
-using std::endl;
-using std::cin;
-
-int main()
-{
- int age = 0;
-
- cout << "Enter your age: ";
- cin >> age;
-
- // Breakpoint 1
- // Put a breakpoint on the following line
- if (age = 1)
- cout << "First Birthday" << endl;
- else if (age >= 12 || age <= 19)
- cout << "Teenager" << endl;
- else if (age < 12)
- cout << "Child" << endl;
- else if (age > 62)
- cout << "Senior" << endl;
- // Breakpoint 2
- // Put a breakpoint on the following line
- else;
- cout << "Adult" << endl;
-
- return 0;
-} \ No newline at end of file
+/********************************************************************
+* File: CST116-Ch7-Debugging.cpp
+*Lloyd Crawford, CST 116 02, CH 7 Debugging, IDE, Simple Program, Github
+* General Instructions: Complete each step before proceeding to the
+* next.
+*
+* Debugging Exercise 1
+*
+* 1) Insert a breakpoint on the lines indicated in the code.
+* 2) Run to Breakpoint 1.
+* 3) When prompted, enter your age.
+* 4) When the execution stops, add a watch on age and verify that
+* the value in age is what you typed in.
+* 5) Step over the if statement.
+* 6) Why did the value in age change?
+* 7) Fix the problem and repeat Steps 2 � 5 to verify the
+* problem was corrected.
+* 8) Stop debugging.
+*
+* Debugging Exercise 2
+*
+* 1) Run to Breakpoint 1.
+* 2) When prompted, enter the value 25 for your age.
+* 3) Step over the if statement. Execution of the program should
+* continue on the else if statement.
+* 4) Verify that 25 is still stored in age.
+* 5) Step over the else if.
+* 6) Why is the program going to print "Teenager" for an age of 25?
+* 7) Fix the problem and repeat Steps 1 � 5 to verify the
+* problem was corrected.
+* 8) Stop debugging.
+* 9) Remove Breakpoint1.
+*
+* Debugging Exercise 3
+*
+* 1) Run the program without debugging.
+* 2) When prompted, enter the value of 10 for your age.
+* 3) Why does the program print both "Child" and "Adult"?
+* 4) Re-run the program this time with debugging and run to
+* Breakpoint 2.
+* 5) Why is the action with the else executing?
+* 6) Fix the problem and re-run to verify the problem was corrected.
+********************************************************************/
+
+#include <iostream>
+using std::cout;
+using std::endl;
+using std::cin;
+
+int main()
+{
+ int age = 0;
+
+ cout << "Enter your age: ";
+ cin >> age;
+
+ // Breakpoint 1
+ // Put a breakpoint on the following line
+ if (age == 1) //Code fix here as = assigns, needed == to test for equality
+ cout << "First Birthday" << endl;
+ else if (age >= 12 && age <= 19) // needed to change code from ||to && to say
+ // else if (age >= 12 && age <= 19) to remove the option of it displaying teenager for any age over 19
+ cout << "Teenager" << endl;
+ else if (age <= 12) // added = to make it less than or equal to 12
+ cout << "Child" << endl;
+ else if (age >= 62) // added = to say greater than or equal to 62
+ cout << "Senior" << endl;
+ // Breakpoint 2
+ // Put a breakpoint on the following line
+ else;
+ cout << "Adult" << endl;
+
+ return 0;
+}
+// For part 1 you test to see why the age would change to 1 when you are a higher age.
+// Its because it needed a fix as = assigns, needed == to test for equality.
+//For part 2 and part 3 i didnt go in exact order, but through trial & error and problem solving
+// I found these fixes to get the right coding: else if (age >= 12 && age <= 19) // needed to change code from ||to && to say
+// else if (age >= 12 && age <= 19) to remove the option of it displaying teenager for any age over 19
+// cout << "Teenager" << endl; else if (age <= 12) // added = to make it less than or equal to 12
+//cout << "Child" << endl; else if (age >= 62) // added = to say greater than or equal to 62
+//cout << "Senior" << endl;
+//Hope this helps. \ No newline at end of file
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Crawford.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Crawford.cpp
new file mode 100644
index 0000000..a4b0826
--- /dev/null
+++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Crawford.cpp
@@ -0,0 +1,83 @@
+/********************************************************************
+* File: CST116-Ch7-Debugging.cpp
+*Lloyd Crawford, CST 116 02, CH 7 Debugging, IDE, Simple Program, Github
+* General Instructions: Complete each step before proceeding to the
+* next.
+*
+* Debugging Exercise 1
+*
+* 1) Insert a breakpoint on the lines indicated in the code.
+* 2) Run to Breakpoint 1.
+* 3) When prompted, enter your age.
+* 4) When the execution stops, add a watch on age and verify that
+* the value in age is what you typed in.
+* 5) Step over the if statement.
+* 6) Why did the value in age change?
+* 7) Fix the problem and repeat Steps 2 � 5 to verify the
+* problem was corrected.
+* 8) Stop debugging.
+*
+* Debugging Exercise 2
+*
+* 1) Run to Breakpoint 1.
+* 2) When prompted, enter the value 25 for your age.
+* 3) Step over the if statement. Execution of the program should
+* continue on the else if statement.
+* 4) Verify that 25 is still stored in age.
+* 5) Step over the else if.
+* 6) Why is the program going to print "Teenager" for an age of 25?
+* 7) Fix the problem and repeat Steps 1 � 5 to verify the
+* problem was corrected.
+* 8) Stop debugging.
+* 9) Remove Breakpoint1.
+*
+* Debugging Exercise 3
+*
+* 1) Run the program without debugging.
+* 2) When prompted, enter the value of 10 for your age.
+* 3) Why does the program print both "Child" and "Adult"?
+* 4) Re-run the program this time with debugging and run to
+* Breakpoint 2.
+* 5) Why is the action with the else executing?
+* 6) Fix the problem and re-run to verify the problem was corrected.
+********************************************************************/
+
+#include <iostream>
+using std::cout;
+using std::endl;
+using std::cin;
+
+int main()
+{
+ int age = 0;
+
+ cout << "Enter your age: ";
+ cin >> age;
+
+ // Breakpoint 1
+ // Put a breakpoint on the following line
+ if (age == 1) //Code fix here as = assigns, needed == to test for equality
+ cout << "First Birthday" << endl;
+ else if (age >= 12 && age <= 19) // needed to change code from ||to && to say
+ // else if (age >= 12 && age <= 19) to remove the option of it displaying teenager for any age over 19
+ cout << "Teenager" << endl;
+ else if (age <= 12) // added = to make it less than or equal to 12
+ cout << "Child" << endl;
+ else if (age >= 62) // added = to say greater than or equal to 62
+ cout << "Senior" << endl;
+ // Breakpoint 2
+ // Put a breakpoint on the following line
+ else;
+ cout << "Adult" << endl;
+
+ return 0;
+}
+// For part 1 you test to see why the age would change to 1 when you are a higher age.
+// Its because it needed a fix as = assigns, needed == to test for equality.
+//For part 2 and part 3 i didnt go in exact order, but through trial & error and problem solving
+// I found these fixes to get the right coding: else if (age >= 12 && age <= 19) // needed to change code from ||to && to say
+// else if (age >= 12 && age <= 19) to remove the option of it displaying teenager for any age over 19
+// cout << "Teenager" << endl; else if (age <= 12) // added = to make it less than or equal to 12
+//cout << "Child" << endl; else if (age >= 62) // added = to say greater than or equal to 62
+//cout << "Senior" << endl;
+//Hope this helps.
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj
index 45b2819..81f3831 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj
+++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj
@@ -24,6 +24,7 @@
<ProjectGuid>{b0d44148-ec98-40c2-9b22-161d71c6254b}</ProjectGuid>
<RootNamespace>CST116Ch7Debugging</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ <ProjectName>CST116-Ch7-Debugging-Crawford</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -127,7 +128,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="CST116-Ch7-Debugging.cpp" />
+ <ClCompile Include="CST116-Ch7-Debugging-Crawford.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters
index a245946..c9bd1e4 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters
+++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters
@@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="CST116-Ch7-Debugging.cpp">
+ <ClCompile Include="CST116-Ch7-Debugging-Crawford.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>