aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch7-Debugging-Bishop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CST116-Ch7-Debugging-Bishop.cpp')
-rw-r--r--CST116-Ch7-Debugging-Bishop.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/CST116-Ch7-Debugging-Bishop.cpp b/CST116-Ch7-Debugging-Bishop.cpp
new file mode 100644
index 0000000..3e3df47
--- /dev/null
+++ b/CST116-Ch7-Debugging-Bishop.cpp
@@ -0,0 +1,78 @@
+//William Bishop
+
+/********************************************************************
+* 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? I had to fix the relational operators. I looked at the problem and I realized that I needed to add an equals sign at the end of the equals one statement. I needed to add another equals sign inside of the first birthday statement.
+* 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? I need to put in the and statement inside the work of what is the parentheses for the
+ logical operators. There was no designation for something that is the work of the 25 in the else it statement. It might have been we needing to edit the statement. It could have been something with the operators.
+* 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"? I looks like the sem colon after the else was changing the output
+* 4) Re-run the program this time with debugging and run to
+* Breakpoint 2.
+* 5) Why is the action with the else executing? I needed to remove the semi colon to let the function run and skip the adult because that was being added with the semi colon after the else statement.
+* 6) Fix the problem and re-run to verify the problem was corrected.
+********************************************************************/
+
+#include <iostream>
+using namespace std;
+using std::cout;
+using std::endl;
+using std::cin;
+
+int main()
+{
+ int age ;
+
+ 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