aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevidavis04 <[email protected]>2022-10-12 18:14:12 -0700
committerGitHub <[email protected]>2022-10-12 18:14:12 -0700
commit5d786bfec01a2c96ffe9b1f26253e6d88f570a29 (patch)
tree94534e5065c0a23ada43d60a42953ee8994ba6c0
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-ch7-debugging-levidavis04-5d786bfec01a2c96ffe9b1f26253e6d88f570a29.tar.xz
cst116-ch7-debugging-levidavis04-5d786bfec01a2c96ffe9b1f26253e6d88f570a29.zip
Add files via upload
-rw-r--r--CST116-Ch7-Debug-Output-Davis.rtf17
-rw-r--r--CST116-ch7-Debug-PSEUDOCODE-Davis.rtf28
-rw-r--r--main.cpp76
3 files changed, 121 insertions, 0 deletions
diff --git a/CST116-Ch7-Debug-Output-Davis.rtf b/CST116-Ch7-Debug-Output-Davis.rtf
new file mode 100644
index 0000000..2889d05
--- /dev/null
+++ b/CST116-Ch7-Debug-Output-Davis.rtf
@@ -0,0 +1,17 @@
+{\rtf1\ansi\ansicpg1252\cocoartf2639
+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Menlo-Bold;\f2\fnil\fcharset0 Menlo-Regular;
+}
+{\colortbl;\red255\green255\blue255;\red255\green255\blue255;\red31\green31\blue36;}
+{\*\expandedcolortbl;;\csgenericrgb\c100000\c100000\c100000;\csgenericrgb\c12054\c12284\c14131;}
+\margl1440\margr1440\vieww11520\viewh8400\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
+
+\f0\fs24 \cf0 Output:\
+\
+\pard\tx593\pardeftab593\pardirnatural\partightenfactor0
+
+\f1\b \cf2 \cb3 Enter your age:
+\f2\b0 18
+\f1\b \
+Teenager\
+Program ended with exit code: 0} \ No newline at end of file
diff --git a/CST116-ch7-Debug-PSEUDOCODE-Davis.rtf b/CST116-ch7-Debug-PSEUDOCODE-Davis.rtf
new file mode 100644
index 0000000..424a747
--- /dev/null
+++ b/CST116-ch7-Debug-PSEUDOCODE-Davis.rtf
@@ -0,0 +1,28 @@
+{\rtf1\ansi\ansicpg1252\cocoartf2639
+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+{\*\expandedcolortbl;;}
+\margl1440\margr1440\vieww11520\viewh8400\viewkind0
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
+
+\f0\fs24 \cf0 Pseudo Code\
+\
+Set age to 0\
+\
+Print \'93Enter your age: \'93\
+User entry = age\
+\
+If age = 1\
+ Print \'93First Birthday\'94\
+Else if age < 12 and > 1\
+ Print \'93Child\'94\
+Else if age >= 12 and <=19\
+ Print \'93Teenager\'94\
+Else if age > 62\
+ Print \'93Senior\'94\
+\
+Else \
+ Print \'93Adult\'94\
+\
+Return age = 0\
+} \ No newline at end of file
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..61479fd
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,76 @@
+//
+// main.cpp
+// CST116 Chapter 7 debugging exercises Davis
+//
+// Created by Levi on 10/12/22.
+//
+/********************************************************************
+* 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;
+
+ if (age == 1)
+ cout << "First Birthday" << endl;
+ else if (age < 12 && age > 1)
+ cout << "Child" << endl;
+ else if (age >= 12 && age <= 19)
+ cout << "Teenager" << endl;
+ else if (age > 62)
+ cout << "Senior" << endl;
+
+ else
+ cout << "Adult" << endl;
+
+ return 0;
+}