aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonCr <[email protected]>2022-10-12 18:22:38 -0700
committerJonCr <[email protected]>2022-10-12 18:22:38 -0700
commit6c1622282af965a4b7d32fd5f4da0909daca376b (patch)
treed4239d854aac0a88abbfd7cfb44f94ec0e44bce0
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-ch7-debugging-cognitiveshadow-6c1622282af965a4b7d32fd5f4da0909daca376b.tar.xz
cst116-ch7-debugging-cognitiveshadow-6c1622282af965a4b7d32fd5f4da0909daca376b.zip
FinishedHEADmain
-rw-r--r--CST116-Ch7-Crombie-pseudo-code.txt13
-rw-r--r--CST116-Ch7-Crombie.txt23
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp11
3 files changed, 43 insertions, 4 deletions
diff --git a/CST116-Ch7-Crombie-pseudo-code.txt b/CST116-Ch7-Crombie-pseudo-code.txt
new file mode 100644
index 0000000..b47101c
--- /dev/null
+++ b/CST116-Ch7-Crombie-pseudo-code.txt
@@ -0,0 +1,13 @@
+Set age equal to 0
+Display "Enter your age: "
+Input age
+If age is equal to 1
+ Display "First Birthday"
+If age is between 12 and 19
+ Display "Teenager"
+If age is under 12 but not equal to 1
+ Display "Child"
+If age is greater than 62
+ Display "Senior"
+If age is not a value that falls into another condition
+ Display "Adult" \ No newline at end of file
diff --git a/CST116-Ch7-Crombie.txt b/CST116-Ch7-Crombie.txt
new file mode 100644
index 0000000..2a225c2
--- /dev/null
+++ b/CST116-Ch7-Crombie.txt
@@ -0,0 +1,23 @@
+Enter your age: 18
+Teenager
+
+C:\Users\JonCr\Source\Repos\cst116-ch7-debugging-CognitiveShadow\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 14936) exited with code 0.
+Press any key to close this window . . .
+
+
+
+Enter your age: 25
+Adult
+
+C:\Users\JonCr\Source\Repos\cst116-ch7-debugging-CognitiveShadow\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 14392) exited with code 0.
+Press any key to close this window . . .
+
+
+
+Enter your age: 10
+Child
+
+C:\Users\JonCr\Source\Repos\cst116-ch7-debugging-CognitiveShadow\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe (process 18568) exited with code 0.
+Press any key to close this window . . .
+
+
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
index f64adfe..a35b784 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
+++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
@@ -13,6 +13,7 @@
* the value in age is what you typed in.
* 5) Step over the if statement.
* 6) Why did the value in age change?
+* A) The if statement set age equal to 1 instead.
* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -26,6 +27,7 @@
* 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?
+* A) Because 25 is greater than 12, and an or operator was used instead of and.
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -39,6 +41,7 @@
* 4) Re-run the program this time with debugging and run to
* Breakpoint 2.
* 5) Why is the action with the else executing?
+* A) A semicolon was placed after the "else," ending it early and letting the cout for "Adult" execute every time.
* 6) Fix the problem and re-run to verify the problem was corrected.
********************************************************************/
@@ -56,9 +59,9 @@ int main()
// Breakpoint 1
// Put a breakpoint on the following line
- if (age = 1)
+ if (age == 1)
cout << "First Birthday" << endl;
- else if (age >= 12 || age <= 19)
+ else if (age >= 12 && age <= 19)
cout << "Teenager" << endl;
else if (age < 12)
cout << "Child" << endl;
@@ -66,8 +69,8 @@ int main()
cout << "Senior" << endl;
// Breakpoint 2
// Put a breakpoint on the following line
- else;
- cout << "Adult" << endl;
+ else
+ cout << "Adult" << endl;
return 0;
} \ No newline at end of file