CSIS 10A Assignment 3 Read: Hennefeld, Chapter 4 Select 10 Points from below Name____________________________ Item Exercises Ch 4 Exercises 5, 6, 10, 12, 15 Additional Exercises on back Points 4 2 Labs Lab4If.cpp 3 Ch 4 Programming Problems EVERYONE DO AT LEAST ONE Problem 17 teen.cpp Problem 18 tshirts.cpp Problem 22 cards.cpp Challenge Problem 25 ( commas.cpp) or 26 (tuition.cpp) Total Possible 10 points + 1 point extra credit 2 2 2 4 11 max PROGRAM TEST PLANS ½ pt off for each test case that does not work after basic program works add a for loop (shown last week) to run multiple cases Problem 17 Test Case 1 2 3 4 teen.cpp Input Data 14 5 26 -5 ( or 112) (see pass.cpp, p77/78 for verifying input example) Expected Result a teen! wow! too young too old invalid age! Problem 18 Test Case 1 2 3 4 5 tshirts.cpp Input Data 2 3 10 25 -5 Problem 22 Test Case 1 2 3 cards.cpp (see suit.cpp, p75) Input Data C5 S 12 (do not make it S Q, that's too hard!) H 13 (see cost.cpp, cost2.cpp p67 – 68) Expected Result $ 24 $ 30 $ 70 Too many--buy 24 or less illegal value Expected Result Five of Clubs Queen of Spades King of Hearts Additional Assignment 3 Exercises 2 points 1) Determine whether the following conditions are true or false. Assume that the following variables have been declared and given the values shown. double a = 5.0, b = 10.0, k = 2.0; a != 3.0 – k a + b >= 6.5 a > 10 || a < 6 !(k < 10) 2) Given the values for the int variables a and b, what is the output of the following program segments? A) a = 5; b = 5; if (a = = b && a > 0) cout << "alpha"; cout << "gamma"; A) Output: C) a = 0; b = 0; if (a = = b && a > 0) cout << "alpha"; cout << "gamma"; C) Output: B) a = 5; b = 5; if (a = = b) if (a<0) cout << "alpha"; else cout << "gamma"; B) Output: D) a = 5; b = 5; if (a = = b) if (a>0) cout << "alpha"; else cout << "gamma"; D) Output: 3) which is true when both a & b are zero, false otherwise a) (a = = 0) && (b = = 0) b) (a = = 0) | | (b = = 0 ) c) (a ! = 0) | | (b ! = 0 ) d) (a ! = 0) && (b ! = 0 ) 4) Which expression selects the condition that the four variables a, b, c and d are the same. a) (a = = b && b = = c && c = = d) b) (a = = b || b = = c || c = = d) c) (a != b && b != c && c ! = d) d) ! (a = = b || b = = c || c = = d) 5) Suppose you have two variables, a and b. condition that none of the variables is zero: a) (a = = 0 || b = = 0 ) b) (a = = 0 && b = = 0 ) c) (a ! = 0 && b ! = 0 ) d) (a ! = 0 || b ! = 0 ) Which expression will select the