diff options
| author | WilliamBishopCST116 <[email protected]> | 2022-10-11 14:15:14 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-10-11 14:15:14 -0700 |
| commit | 68ae882ebca921a81a882f62373812d05438a9d4 (patch) | |
| tree | 21c7cf771978ad4b947fbc494f5327890150862e | |
| parent | Setting up GitHub Classroom Feedback (diff) | |
| download | cst116-ch7debugging-bishop-main.tar.xz cst116-ch7debugging-bishop-main.zip | |
| -rw-r--r-- | CST116-CH7Debugging-Bishop-Pseudocode.txt | 78 | ||||
| -rw-r--r-- | CST116-CH7Debugging-Bishop.txt | 5 | ||||
| -rw-r--r-- | CST116-Ch7-Debugging-Bishop.cpp | 78 |
3 files changed, 161 insertions, 0 deletions
diff --git a/CST116-CH7Debugging-Bishop-Pseudocode.txt b/CST116-CH7Debugging-Bishop-Pseudocode.txt new file mode 100644 index 0000000..65d7d7c --- /dev/null +++ b/CST116-CH7Debugging-Bishop-Pseudocode.txt @@ -0,0 +1,78 @@ +//William Bishop
+ Here I have my contact information.
+/********************************************************************
+* 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> Here we are including the io stream.
+using namespace std; I am putting in the namespace std outputting.
+using std::cout; Here we can use the cout command.
+using std::endl; Here we are using the end line output command.
+using std::cin; Here we are using the cin command.
+
+int main() Here is the start of the main function in the program.
+{
+ int age ; Here we have the integer age.
+
+ cout << "Enter your age: "; Here we ask for a cout in the integer of age.
+ cin >> age; Here we get the input for age.
+
+ // Breakpoint 1
+ // Put a breakpoint on the following line
+ if (age == 1)
+ cout << "First Birthday" << endl; Here is if age = 1 we get the first birthday cout statement.
+ else if (age >= 12 && age <= 19)
+ cout << "Teenager" << endl; If age is a number from 12 to nineteen we get the Teenager output.
+ else if (age < 12)
+ cout << "Child" << endl; Here we have the age less than 12 being a child.
+ else if (age > 62)
+ cout << "Senior" << endl; Here we have the work of what is the age being past 62 we get the Senior output from the else statement.
+ // Breakpoint 2
+ // Put a breakpoint on the following line
+ else
+ cout << "Adult" << endl; If we have any number that isn't what was listed above we have the Adult output.
+
+ return 0;
+}
\ No newline at end of file diff --git a/CST116-CH7Debugging-Bishop.txt b/CST116-CH7Debugging-Bishop.txt new file mode 100644 index 0000000..b2860ca --- /dev/null +++ b/CST116-CH7Debugging-Bishop.txt @@ -0,0 +1,5 @@ +
+
+
+Enter your age: 10
+Child
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 |