aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
diff options
context:
space:
mode:
authorEvan <[email protected]>2022-10-11 20:03:59 -0700
committerEvan <[email protected]>2022-10-11 20:03:59 -0700
commitea1bc343679954b82538659d12feb825780789cd (patch)
tree4caf93dda142778a9896a62a6ceae766931df0b6 /CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
parent1st (diff)
downloadcst116-ch7-debugging-evanmihm-ea1bc343679954b82538659d12feb825780789cd.tar.xz
cst116-ch7-debugging-evanmihm-ea1bc343679954b82538659d12feb825780789cd.zip
anwsers
Diffstat (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp')
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
index f64adfe..4b708dd 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
+++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
@@ -13,6 +13,9 @@
* the value in age is what you typed in.
* 5) Step over the if statement.
* 6) Why did the value in age change?
+*
+* the if statement is setting age value to 1
+*
* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -26,6 +29,9 @@
* 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?
+*
+* because it is using || instead of &&
+*
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -36,16 +42,22 @@
* 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"?
+*
+* mine is working how it should
+*
* 4) Re-run the program this time with debugging and run to
* Breakpoint 2.
* 5) Why is the action with the else executing?
+*
+* mine is working how it should
+*
* 6) Fix the problem and re-run to verify the problem was corrected.
********************************************************************/
#include <iostream>
using std::cout;
-using std::endl;
using std::cin;
+using std::endl;
int main()
{
@@ -56,18 +68,21 @@ 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)
- cout << "Teenager" << endl;
+
else if (age < 12)
cout << "Child" << endl;
- else if (age > 62)
+
+ else if (age >= 12 && age <= 19)
+ cout << "Teenager" << endl;
+
+ else if (age >= 62)
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