From d24d7a554d1fc4ae0be94b57c6238c786ff80193 Mon Sep 17 00:00:00 2001 From: Anibal LopezBonilla Date: Wed, 12 Oct 2022 20:28:41 -0700 Subject: Push 4 --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index 1f9b6db..eedcdbb 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -30,7 +30,7 @@ * 5) Step over the else if. * 6) Why is the program going to print "Teenager" for an age of 25? * -* ANS: There is if statement to take into account for the ages of 21 and up. +* ANS: There is no if statement to take into account for the ages of 21 and up. * * 7) Fix the problem and repeat Steps 1 – 5 to verify the * problem was corrected. @@ -44,9 +44,14 @@ * 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"? +* +* ANS: Because the else statement was nnot supposed to have a colon at the end. + * 4) Re-run the program this time with debugging and run to * Breakpoint 2. * 5) Why is the action with the else executing? +* +* ANS: The else statement was not active due to the colon. * 6) Fix the problem and re-run to verify the problem was corrected. ********************************************************************/ @@ -57,6 +62,28 @@ using std::cin; int main() { + + /*int age = 0; + + 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;*/ int age = 0; cout << "Enter your age: "; @@ -77,5 +104,4 @@ int main() else cout << "Adult" << endl; - return 0; } \ No newline at end of file -- cgit v1.2.3