// Copyright Amruth N. Kumar, amruth@computer.org // Syntax: // Comment for reader's benefit, not parsed // # Template Number - +100 for each new type of problem, +10 for each new subtype // Learning Objective(s) for this template - when this template should be used // ? // If student gets the answer right, what OTHER objectives should get credit // Usually, counterpoint to the point of the error, say allocation for missing // deallocation, Declaration for out of scope error, assignment for incorrect // referencing, etc. // Make sure there is no overlap between this and antecedents! // : // If student gets the answer wrong, what OTHER objectives should get discredit // Make sure there is no overlap between this and antecedents! // > // The template itself, no double quotes, preceded and succeeded by a single > // > // Type: debug / output / code // Hardness: The student's correct percentage up to which this template will be used // Note: Syntax for learning objectives (in antecedent, ifCorrect, ifWrong) // is dot.separated, with {,} to represent alternates. // e.g., a.{b,c} is a.b and a.c // This is NOT graph structured, i.e., a,{b,c}.d is not accounted for to mean // a.b.d or a.c.d // FUTURE IMPROVEMENTS // ------------------------------------------------------------------------------- // The actual learning objectives: // // 100 - output, changed to debug_output for consistency // Switch.Condition.Matches case // 125 - output, changed to debug_output for consistency // Switch.Condition.Matches default // 150 - output, changed to debug_output for consistency // Switch.Condition.Matches none // 175 - output, changed to debug_output for consistency // Switch.Condition.Expression // // 200 - Done by RWalde - debug_output // Switch.Condition.Switch condition is not an integer expression // 225 - Done by RWalde - debug_output // Switch.Case.Case value is not an integer expression // 250 - Done by RWalde - debug_output // Switch.Case.Case value is not a constant expression // // 300 - output, changed to debug_output for consistency // Switch.Body.No statement // // 325 - debug_output // Switch.Body.No break.Has statements // 350 - debug_output // Switch.Body.No break.No statement // // 400 - output // Switch.Nested // 500 - output // Switch.Multiple // // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // 100 // Switch.Condition.Matches case // Always has default, never used; all cases have break and at least one statement // Case value options: // 1-5 // 5 random values // 50-10 // Body of switch options: // Print random constants // Print an expression involving case value, e.g., monotonic up or exchange // Print an expression involving a variable other than the one in the condition // Assign to a variable, which is printed after the switch // Random value // Value of an expression involving case value // 1-5 cases # 100 Switch.Condition.Matches case > {(){=;switch(){ case 1: << ; break; case 2: << ; break; case 3: << ; break; case 4: << ; break; case 5: << ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 101 Switch.Condition.Matches case > {(){=;switch(){ case 1: << + 4; break; case 2: << + 2; break; case 3: << ; break; case 4: << - 2; break; case 5: << - 4; break; default: << * ; break; }}} > Type: debug_output Hardness: 20 # 102 Switch.Condition.Matches case > {(){=;=;switch(){ case 1: << * ; break; case 2: << - ; break; case 3: << + ; break; case 4: << - ; break; case 5: << + ; break; default: << * ; break; }}} > Type: debug_output Hardness: 20 # 103 Switch.Condition.Matches case > {(){=;;switch(){ case 1: = * 10; break; case 2: = + 10; break; case 3: = 0; break; case 4: = + 2; break; case 5: = * 2; break; default: = % 10; break; } << ;}} > Type: debug_output Hardness: 20 // 5 random values for cases # 105 Switch.Condition.Matches case > {(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 106 Switch.Condition.Matches case > {(){=;switch(){ case : << - 20; break; case : << + 20; break; case : << - 10; break; case : << 50 - ; break; case : << + 10; break; default: << + ; break; }}} > Type: debug_output Hardness: 20 # 107 Switch.Condition.Matches case > {(){=;=;switch(){ case : << * ; break; case : << / ; break; case : << + ; break; case : << % ; break; case : << - ; break; default: << * ; break; }}} > Type: debug_output Hardness: 20 # 108 Switch.Condition.Matches case > {(){=;=;switch(){ case : = * 10; break; case : = % ; break; case : = + 10; break; case : = / ; break; case : = - ; break; default: = * ; break; } << ;}} > Type: debug_output Hardness: 20 // cases 50-10 # 110 Switch.Condition.Matches case > // {(){ = * 10;switch(){ case 50: << ; break; case 40: << ; break; case 30: << ; break; case 20: << ; break; case 10: << ; break; default: << ; break; }}} []{(){ = ;switch(){ case 50: << ; break; case 40: << ; break; case 30: << ; break; case 20: << ; break; case 10: << ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 111 Switch.Condition.Matches case > // {(){ = * 2;switch(){ case 10: << / 10; break; case 8: << + ; break; case 6: << ; break; case 4: << - ; break; case 2: << * ; break; default: << % 10; break; }}} []{(){ = ;switch(){ case 10: << / 10; break; case 8: << + ; break; case 6: << ; break; case 4: << - ; break; case 2: << * ; break; default: << % 10; break; }}} > Type: debug_output Hardness: 20 # 112 Switch.Condition.Matches case > // {(){ = * 5; = * 10;switch(){ case 25: << - ; break; case 20: << / 10; break; case 15: << / 10; break; case 10: << + ; break; case 5: << - ; break; default: << * ; break; }}} [,]{(){ = ; = ;switch(){ case 25: << - ; break; case 20: << / 10; break; case 15: << / 10; break; case 10: << + ; break; case 5: << - ; break; default: << * ; break; }}} > Type: debug_output Hardness: 20 # 113 Switch.Condition.Matches case > // {(){ = * 10;;switch(){ case 90: = / 10; break; case 80: = - 30; break; case 70: = ; break; case 60: = + 20; break; case 50: = * 2; break; default: = % 10; break; } << ;}} []{(){ = ;;switch(){ case 90: = / 10; break; case 80: = - 30; break; case 70: = ; break; case 60: = + 20; break; case 50: = * 2; break; default: = % 10; break; } << ;}} > Type: debug_output Hardness: 20 // --------------------------------------------------------------------------- // 125 // Switch.Condition.Matches default // 1-5 cases # 125 Switch.Condition.Matches default > {(){=;switch(){ case 1: << ; break; case 2: << ; break; case 3: << ; break; case 4: << ; break; case 5: << ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 126 Switch.Condition.Matches default > {(){=;switch(){ case 1: << + ; break; case 2: << % 2; break; case 3: << * 2; break; case 4: << * ; break; case 5: << - ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 127 Switch.Condition.Matches default > {(){=;=;switch(){ case 1: << % ; break; case 2: << - ; break; case 3: << * ; break; case 4: << - ; break; case 5: << % ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 128 Switch.Condition.Matches default > {(){=;;switch(){ case 1: = + ; break; case 2: = * ; break; case 3: = % 10; break; case 4: = / 3; break; case 5: = ; break; default: = + 1; break; } << ;}} > Type: debug_output Hardness: 20 // 5 random values for cases # 130 Switch.Condition.Matches default > {(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 131 Switch.Condition.Matches default > {(){=;switch(){ case : << - ; break; case : << * ; break; case : << - ; break; case : << + ; break; case : << - ; break; default: << - 40; break; }}} > Type: debug_output Hardness: 20 # 132 Switch.Condition.Matches default > {(){=;=;switch(){ case : << % ; break; case : << / ; break; case : << + ; break; case : << % ; break; case : << / ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 133 Switch.Condition.Matches default > {(){=;=;switch(){ case : = / 10; break; case : = % ; break; case : = / ; break; case : = % ; break; case : = * 10; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 20 // cases 50-10 # 135 Switch.Condition.Matches default > // {(){ = * 10;switch(){ case 90: << ; break; case 80: << ; break; case 70: << ; break; case 60: << ; break; case 50: << ; break; default: << ; break; }}} []{(){ = ;switch(){ case 90: << ; break; case 80: << ; break; case 70: << ; break; case 60: << ; break; case 50: << ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 136 Switch.Condition.Matches default > // {(){ = * 2;switch(){ case 9: << % 10; break; case 7: << % 2; break; case 5: << * ; break; case 3: << / 10; break; case 1: << * 5; break; default: << / 2; break; }}} []{(){ = ;switch(){ case 9: << % 10; break; case 7: << % 2; break; case 5: << * ; break; case 3: << / 10; break; case 1: << * 5; break; default: << / 2; break; }}} > Type: debug_output Hardness: 20 # 137 Switch.Condition.Matches default > // {(){ = * 10; = * 10;switch(){ case 50: << * 10; break; case 40: << * ; break; case 30: << * 5; break; case 20: << * 2; break; case 10: << * ; break; default: << ; break; }}} [,]{(){ =; = ;switch(){ case 50: << * 10; break; case 40: << * ; break; case 30: << * 5; break; case 20: << * 2; break; case 10: << * ; break; default: << ; break; }}} > Type: debug_output Hardness: 20 # 138 Switch.Condition.Matches default > // {(){ = * 5;;switch(){ case 50: = % 5; break; case 45: = / 10; break; case 40: = % 10; break; case 35: = / 5; break; case 30: = % 2; break; default: = * 2; break; } << ;}} []{(){ = ;;switch(){ case 50: = % 5; break; case 45: = / 10; break; case 40: = % 10; break; case 35: = / 5; break; case 30: = % 2; break; default: = * 2; break; } << ;}} > Type: debug_output Hardness: 20 // --------------------------------------------------------------------------- // 150 // Switch.Condition.Matches none // 1-5 cases # 150 Switch.Condition.Matches none > {(){=;switch(){ case 1: << ; break; case 2: << ; break; case 3: << ; break; case 4: << ; break; case 5: << ; break; }}} > Type: debug_output Hardness: 20 # 151 Switch.Condition.Matches none > {(){ = ;switch(){ case 5: << + ; break; case 6: << - ; break; case 7: << * 2; break; case 8: << % 2; break; case 9: << * ; break; }}} > Type: debug_output Hardness: 20 # 152 Switch.Condition.Matches none > // {(){ = * 10;=;switch(){ case 3: << % ; break; case 4: << % 10; break; case 5: << + ; break; case 6: << - ; break; case 7: << % ; break; } << ;}} []{(){ = ;=;switch(){ case 3: << % ; break; case 4: << % 10; break; case 5: << + ; break; case 6: << - ; break; case 7: << % ; break; } << ;}} > Type: debug_output Hardness: 20 # 153 Switch.Condition.Matches none > // {(){ = * 2;=;switch(){ case 1: = * ; break; case 2: = / 2; break; case 3: = * 10; break; case 4: = % 2; break; case 5: = / ; break; } << ;}} []{(){ =;=;switch(){ case 1: = * ; break; case 2: = / 2; break; case 3: = * 10; break; case 4: = % 2; break; case 5: = / ; break; } << ;}} > Type: debug_output Hardness: 20 // 5 random values for cases # 155 Switch.Condition.Matches none > {(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; }}} > Type: debug_output Hardness: 20 # 156 Switch.Condition.Matches none > {(){=;switch(){ case : << - ; break; case : << + ; break; case : << - ; break; case : << - ; break; case : << - ; break; }}} > Type: debug_output Hardness: 20 # 157 Switch.Condition.Matches none > {(){=;=;switch(){ case : = - ; break; case : = / ; break; case : = / ; break; case : = - ; break; case : = - ; break; } << ; }} > Type: debug_output Hardness: 20 # 158 Switch.Condition.Matches none > {(){=;=;switch(){ case : = + ; break; case : = / ; break; case : = % ; break; case : = - ; break; case : = - ; break; } << ;}} > Type: debug_output Hardness: 20 // cases 50-10 # 160 Switch.Condition.Matches none > // {(){ = * 20;switch(){ case 90: << ; break; case 70: << ; break; case 50: << ; break; case 30: << ; break; case 10: << ; break; }}} []{(){ = ;switch(){ case 90: << ; break; case 70: << ; break; case 50: << ; break; case 30: << ; break; case 10: << ; break; }}} > Type: debug_output Hardness: 20 # 161 Switch.Condition.Matches none > {(){ = ;switch(){ case 4: << / 2; break; case 3: << % 2; break; case 2: << * 2; break; case 1: << * 3; break; case 0: << + 5; break; }}} > Type: debug_output Hardness: 20 # 162 Switch.Condition.Matches none > // {(){ = * 10; = ;switch(){ case 55: = * 2; break; case 45: = * 10; break; case 35: = / ; break; case 25: = / 2; break; case 15: = + ; break; } << ; }} []{(){ = ; = ;switch(){ case 55: = * 2; break; case 45: = * 10; break; case 35: = / ; break; case 25: = / 2; break; case 15: = + ; break; } << ; }} > Type: debug_output Hardness: 20 # 163 Switch.Condition.Matches none > // {(){ = * 5;switch(){ case 20: = - 5; break; case 15: = / 5; break; case 10: = % 5; break; case 5: = * 5; break; case 0: = + 5; break; } << ;}} []{(){ = ;switch(){ case 20: = - 5; break; case 15: = / 5; break; case 10: = % 5; break; case 5: = * 5; break; case 0: = + 5; break; } << ;}} > Type: debug_output Hardness: 20 // --------------------------------------------------------------------------- // 175 // Switch.Condition.Expression // Incrementing # 175 Switch.Condition.Expression > // {(){ = ; = 10;switch( + ){ case 11: << ; break; case 12: << ; break; case 13: << - ; break; case 14: << * ; break; case 15: << * ; break; default: << + ; break; }}} [,]{(){ = ; = ;switch( + ){ case : << ; break; case : << ; break; case : << - ; break; case : << * ; break; case : << * ; break; default: << + ; break; }}} > Type: debug_output Hardness: 40 # 176 Switch.Condition.Expression > // {(){ = ; = 10;switch( - ){ case 5: << * 2; break; case 6: << + ; break; case 7: << * 2; break; case 8: << * ; break; case 9: << - ; break; default: << - ; break; }}} [,]{(){ = ; = ;switch( - ){ case : << * 2; break; case : << + ; break; case : << * 2; break; case : << * ; break; case : << - ; break; default: << - ; break; }}} > Type: debug_output Hardness: 40 # 177 Switch.Condition.Expression > // {(){ = ; = 10;switch( * ){ case 10: << + ; break; case 20: << / ; break; case 30: << - ; break; case 40: << ; break; case 50: << ; break; default: << * ; break; }}} [,]{(){ = ; = ;switch( * ){ case : << + ; break; case : << / ; break; case : << - ; break; case : << ; break; case : << ; break; default: << * ; break; }}} > Type: debug_output Hardness: 40 # 178 Switch.Condition.Expression > {(){ = ; = 12;switch( / ){ case 2: = + 3; break; case 3: = - 2; break; case 4: = - ; break; case 6: = * 2; break; case 12: = + ; break; default: = / ; break; } << ; }} > Type: debug_output Hardness: 45 # 179 Switch.Condition.Expression > {(){ = ; = 10;switch( % ){ case 0: = / ; break; case 1: = * ; break; case 2: = + ; break; case 3: = - ; break; case 4: = * ; break; default: = % ; break; } << ; }} // {(){ = ; = 10;switch( % ){ case 0: = / ; break; case 1: = * ; break; case 2: = + ; break; case 3: = - ; break; case 4: = * ; break; case 5: break; case 6: break; default: = % ; break; } << ; }} > Type: debug_output Hardness: 45 // Decrementing # 185 Switch.Condition.Expression > // {(){ = ; = ;switch( + ){ case 6: << / ; break; case 5: << - ; break; case 4: << * ; break; case 3: << - ; break; case 2: << * ; break; default: << + ; break; }}} [,,,,,,]{(){ = ; = ;switch( + ){ case : << ; break; case : << 10 - ; break; case : << * ; break; case : << 10 - ; break; case : << ; break; default: << + ; break; }}} > Type: debug_output Hardness: 40 # 186 Switch.Condition.Expression > // {(){ = ; = ;switch( - ){ case 2: << + ; break; case 1: << ; break; case 0: << * 2; break; case -1: << ; break; case -2: << - ; break; default: << - ; break; }}} [,,,,,,]{(){ = ; = ;switch( - ){ case : << + ; break; case : << ; break; case : << * 2; break; case : << + 10; break; case : << - ; break; default: << - ; break; }}} > Type: debug_output Hardness: 40 # 187 Switch.Condition.Expression > // {(){ = ; = ;;switch( * ){ case 9: = / ; break; case 6: = * 2; break; case 4: = % ; break; case 3: = * 10; break; case 2: = * 5; break; case 1: = + ; break; default: = * ; break; } << ;}} [,,,,,]{(){ = ; = ;;switch( * ){ case : = + 10; break; case : = + 20; break; case : = + 30; break; case : = + 40; break; case : = + 50; break; case : = + 60; break; default: = + 100; break; } << ;}} > Type: debug_output Hardness: 40 # 188 Switch.Condition.Expression > {(){ = ; = 60;;switch( / ){ case 30: = / 10; break; case 20: = * ; break; case 15: = / 2; break; case 12: = * 2; break; case 10: = + ; break; default: = / ; break; } << ; }} > Type: debug_output Hardness: 45 # 189 Switch.Condition.Expression > // {(){ = ; = 10;;switch( % ){ case 0: = ; break; case 1: = * 2; break; case 2: = / 2; break; case 3: = + 2; break; case 4: = / 3; break; default: = % ; break; } << ; }} [,]{(){ = ; = ;;switch( % ){ case 4: = ; break; case 3: = * 10; break; case 2: = ; break; case 1: = + 20; break; case 0: = * 10; break; default: = % ; break; } << ; }} > Type: debug_output Hardness: 45 // --------------------------------------------------------------------------- // 200 // Switch.Condition.Real // Added by Ralph Walde 1/22/2010 // Condition is variable 200- // Cases are increasing and consecutive or multiples of 5/10/100 // Action prints random constant // Action prints expression involving condition variable // Action assings random value to a secondary variable that is printed after the switch // Condition is expression 205- // Cases are increasing and consecutive or multiples of 5/10/100 // Action prints random constant // Action prints expression involving condition variable // Action assings random value to a secondary variable that is printed after the switch // 2 X 2 X 3 combinations of condition (variable vs expression) X cases (increasing versus decreasing) X action (3 types as listed above) // --------------------------------------------------------------------------- // Added by Ralph Walde 1/22/2010 thru 2/7/2010 // 200 - 224 Switch.Condition.Switch condition is not an integer expression // 225 - 249 Switch.Case.Real // 250 - 274 Switch.Case.Case value is not a constant expression // 200 - 224 Switch.Condition.Switch condition is not an integer expression // 200-202 Condition is real variable // Cases are increasing and consecutive or multiples of 5/10/100 // Action prints random constant // Action prints expression involving condition variable // Action assigns random value to a secondary variable that is printed after the switch // 205-207 Condition is expression involving real variable // Cases are increasing and consecutive or multiples of 5/10/100 // Action prints random constant // Action prints expression involving condition variable // Action assigns random value to a secondary variable that is printed after the switch // 210-212 Condition is real variable, Cases are decreasing, three kinds of action // 215-217 Condition is real variable expression, Cases are decreasing, three kinds of action // 200 switch() Cases increase + 10 to + 50, Random case matches, Action - Cases output random constants # 200 Switch.Condition.Switch condition is not an integer expression > [,,,]{(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 201 switch(), Cases increase + 1 to + 5, Random case matches, Cases output expressions of # 201 Switch.Condition.Switch condition is not an integer expression > [,,,]{(){=;switch(){ case : << + 1; break; case : << * 2; break; case : << - 3; break; case : << - 2; break; case : << * ; break; default: << * 2 + 5; break;}}} > Type: debug_output Hardness: 20 // 202 switch(), Cases increase 5 * + 5 to 5 * + 25, A case matches, Cases assign int , output after switch # 202 Switch.Condition.Switch condition is not an integer expression > [,,,]{(){=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; }<< ;}} > Type: debug_output Hardness: 20 // 205 switch( + ) Cases increase + 1 to + 5, A case matches, Cases output random constants # 205 Switch.Condition.Switch condition is not an integer expression > [,,]{(){=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 30 // 206 switch( * ), Cases increasing int, A case matches, Cases output expressions of # 206 Switch.Condition.Switch condition is not an integer expression > // {(){=;switch( * ){ case : << 2 * ; break; case : << + 5; break; case : << - 3; break; case : << - 6; break; case : << 2 * + 1; break; default: << 1 + ; break; }}} []{(){=;switch( * ){ case : << 2 * ; break; case : << + 5; break; case : << - 3; break; case : << - 6; break; case : << 2 * + 1; break; default: << 1 + ; break; }}} > Type: debug_output Hardness: 30 // 207 switch(10 * ), Increase cases by 10, A case matches, Cases assign int , output after switch # 207 Switch.Condition.Switch condition is not an integer expression > [,,]{(){=;=;switch( * 10){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 30 // 210 switch() Cases decrease + 50 to + 10, Random case matches, Action - Cases output random constants # 210 Switch.Condition.Switch condition is not an integer expression > [,,,]{(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 211 switch(), Cases decrease + 5 to + 1, Random case matches, Cases output expressions of # 211 Switch.Condition.Switch condition is not an integer expression > [,,,]{(){=;switch(){ case : << 9 - ; break; case : << 2 * ; break; case : << + 1; break; case : << - 2; break; case : << * 3; break; default: << + 4; break;}}} > Type: debug_output Hardness: 20 // 212 switch(), Cases decrease 5 * + 25 to 5 * + 5, A case matches, Cases assign int , output after switch # 212 Switch.Condition.Switch condition is not an integer expression > [,,,]{(){=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; }<< ;}} > Type: debug_output Hardness: 20 // 215 switch ( + ) Cases increase + 1 to + 5, A case matches, Cases output random constants # 215 Switch.Condition.Switch condition is not an integer expression > [,,]{(){=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 30 //216 switch( - ) Cases decreasing random int, Matches Default, Cases output expressions of # 216 Switch.Condition.Switch condition is not an integer expression > // {(){=;switch( - ){ case : << * 3; break; case : << + 4; break; case : << - 3; break; case : << 6 - ; break; case : << 2 + ; break; default: << 1 + * 2; break; }}} []{(){=;switch( - ){ case : << * 3; break; case : << + 4; break; case : << - 3; break; case : << 6 - ; break; case : << 2 + ; break; default: << * 2 + 1; break; }}} > Type: debug_output Hardness: 30 // 217 switch(5 * ), Cases decreasing by 5, A case matches, Cases assign int a expression, output after switch # 217 Switch.Condition.Switch condition is not an integer expression > [,,]{(){=;=;switch( * 5){ case : = + ; break; case : = + ; break; case : = + ; break; case : = + ; break; case : = + ; break; default: = + ; break; } << ;}} > Type: debug_output Hardness: 30 // --------------------------------------------------------------------------- // 225 - 249 Switch.Case.Case value is not an integer expression // Added by Ralph Walde 1/22/2010 // 225-227 Case real literal, Condition is int variable, Cases increasing, three kinds of action // 230-232 Case real literal or expression, Condition is int variable expression, Cases increasing, 3 kinds of action // 235-237 Case real literal or expression, Condition is int variable, Cases decreasing, 3 kinds of action // 240-242 Case real literal or expression, Condition is int variable expression, Cases decreasing, 3 kinds of action // 225 One case a literal real, switch() Cases increase + 10 to + 50, Random case matches, Cases output random constants # 225 Switch.Case.Case value is not an integer expression > // [,,,]{(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} [,,]{(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 226 One case a literal real, switch(), Cases increase + 1 to + 5, Random case matches, Cases output expressions of # 226 Switch.Case.Case value is not an integer expression > [,,,]{(){=;switch(){ case : << * 3; break; case : << * 2; break; case : << 9 - ; break; case : << - 2; break; case : << * ; break; default: << 2 * - 6; break;}}} > Type: debug_output Hardness: 20 // 227 One case a literal real, switch(), Cases increase 10 * + 10 to 10 * + 50, A case matches, Cases assign int , output after switch # 227 Switch.Case.Case value is not an integer expression > [,,,]{(){=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; }<< ;}} > Type: debug_output Hardness: 20 // 230 One case literal real, Switch( + ), Cases increase + 1 to + 5, A case matches, Cases output random constants # 230 Switch.Case.Case value is not an integer expression > [,,]{(){=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 231 One case real constant expression, switch( + ), Cases increasing random int, A case matches, Cases output expressions of # 231 Switch.Case.Case value is not an integer expression > // {(){=;switch( + ){ case : << 5 + ; break; case : << - 6; break; case : << 3 * ; break; case : << + 9; break; case + : << 2 * - 3; break; default: << 1 + ; break; }}} {(){=;switch( + ){ case : << 5 + ; break; case : << - 6; break; case : << 3 * ; break; case : << + 9; break; case : << 2 * - 3; break; default: << 1 + ; break; }}} > Type: debug_output Hardness: 20 // 232 One case literal real, switch(10 * ), Cases by 10, A case matches, Cases assign int , output after switch # 232 Switch.Case.Case value is not an integer expression > [,,,]{(){=;=;switch( * 10){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 20 //235 One case a literal real, switch() Cases decrease + 25 to + 5, Random case matches, Cases output random constants # 235 Switch.Case.Case value is not an integer expression > // [,,,]{(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} [,,,]{(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 236 One case a literal real, switch(), Cases decrease + 5 to + 1, Random case matches, Cases output expressions of # 236 Switch.Case.Case value is not an integer expression > [,,,]{(){=;switch(){ case : << * 3; break; case : << * 2; break; case : << 9 - ; break; case : << - 2; break; case : << * ; break; default: << 2 * - 6; break;}}} > Type: debug_output Hardness: 20 // 237 One case a real constant expression, switch(), Cases decrease 10 * + 50 to 10 * + 10, A case matches, Cases assign int , output after switch # 237 Switch.Case.Case value is not an integer expression > // [,,,]{(){=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case 20 + : = ; break; case : = ; break; default: = ; break; }<< ;}} [,,,]{(){=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; }<< ;}} > Type: debug_output Hardness: 20 // 240 One case literal real, Switch( + ), Cases decrease + 5 to + 1, A case matches, Cases output random constants # 240 Switch.Case.Case value is not an integer expression > // [,,]{(){=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} [,,]{(){=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 241 One case literal, switch( + ), Cases decreasing random int, A case matches, Cases output expressions of # 241 Switch.Case.Case value is not an integer expression > // {(){=;switch( + ){ case : << - ; break; case : << + ; break; case : << * 2; break; case : << + ; break; case : << 2 * - ; break; default: << + ; break; }}} {(){=;switch( + ){ case : << - ; break; case : << + ; break; case : << * 2; break; case : << + ; break; case : << 2 * - ; break; default: << + ; break; }}} > Type: debug_output Hardness: 20 // 242 One case literal real, switch( * 5), Cases decrease by 5, A case matches, Cases assign int , output after switch # 242 Switch.Case.Case value is not an integer expression > [,,,]{(){=;=;switch( * 5){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 20 // --------------------------------------------------------------------------- // 250 - 274 Switch.Case.Case value is not a constant expression // Added by Ralph Walde 1/22/2010 // 250-252 Case integer variable, Condition is int variable, Cases increasing, three kinds of action // 255-257 Case integer variable or expression, Condition is int variable expression, Cases increasing, 3 kinds of action // 260-262 Case integer variable or expression, Condition is int variable, Cases decreasing, 3 kinds of action // 265-267 Case integer variable or expression, Condition is int variable expression, Cases decreasing, 3 kinds of action // 250 One case an integer variable, switch() Cases increase + 10 to + 50, Random case matches, Cases output random constants # 250 Switch.Case.Case value is not a constant expression > [,,]{(){=;=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 251 One case an integer variable, switch(), Cases increase + 1 to + 5, Random case matches, Cases output expressions of # 251 Switch.Case.Case value is not a constant expression > [,,]{(){=;=;switch(){ case : << * 2; break; case : << + ; break; case : << - ; break; case : << + ; break; case : << * ; break; default: << 2 * - ; break;}}} > Type: debug_output Hardness: 20 // 252 One case an integer variable, switch(), Cases increase 10 * + 10 to 10 * + 50, A case matches, Cases assign int , output after switch # 252 Switch.Case.Case value is not a constant expression > [,,,]{(){=;=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; }<< ;}} > Type: debug_output Hardness: 20 // 255 One case an integer variable, Switch( + ), Cases increase + 1 to + 5, A case matches, Cases output random constants # 255 Switch.Case.Case value is not a constant expression > [,,]{(){=;=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 256 One case an integer variable, switch( + ), Cases increasing random int, A case matches, Cases output expressions of # 256 Switch.Case.Case value is not a constant expression > // {(){=;=;switch( + ){ case : << + ; break; case : << - ; break; case : << 2 * ; break; case : << + ; break; case : << 2 * + ; break; default: << + ; break; }}} []{(){=;=;switch( + ){ case : << + ; break; case : << - ; break; case : << 2 * ; break; case : << + ; break; case : << 2 * + ; break; default: << + ; break; }}} > Type: debug_output Hardness: 20 // One case an integer variable expression, switch(10 * ), Cases increases by 10, A case matches, Cases assign int , output after switch # 257 Switch.Case.Case value is not a constant expression > // {(){=;=;=20;switch(10 * ){ case 10: = ; break; case 20: = + ; break; case 30: = * 4; break; case 40: = 5 * + ; break; case 3 * - 10: = 3 * + 2; break; default: = + ; break; }<< ;}} [,,,]{(){=;=;=;switch( * 10){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 20 //260 One case an integer variable, switch() Cases decrease + 25 to + 5, Random case matches, Cases output random constants # 260 Switch.Case.Case value is not a constant expression > [,,,]{(){=;=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 261 One case an integer variable, switch(), Cases decrease + 5 to + 1, Random case matches, Cases output expressions of # 261 Switch.Case.Case value is not a constant expression > [,,,]{(){=;=;switch(){ case : << * 3; break; case : << * 2; break; case : << + ; break; case : << - ; break; case : << * ; break; default: << 2 * - ; break;}}} > Type: debug_output Hardness: 20 // 262 One case an integer variable expression, switch(), Cases decrease 10 * + 50 to 10 * + 10, A case matches, Cases assign int , output after switch # 262 Switch.Case.Case value is not a constant expression > // [,,,]{(){=;=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case + 10: = ; break; default: = ; break; }<< ;}} [,,,]{(){=;=;=;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; }<< ;}} > Type: debug_output Hardness: 20 // 265 One case an integer variable, Switch( + ), Cases decrease + 5 to + 1, A case matches, Cases output random constants # 265 Switch.Case.Case value is not a constant expression > // [,,]{(){=;=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} [,,]{(){=;=;switch( + ){ case : << ; break; case : << ; break; case :<< ; break; case : << ; break; case : << ; break; default: << ; break;}}} > Type: debug_output Hardness: 20 // 266 One case an integer variable expression, switch( + ), Cases decreasing random int, A case matches, Cases output expressions of # 266 Switch.Case.Case value is not a constant expression > // {(){=;=;switch( + ){ case : << - ; break; case : << + ; break; case : << * 2; break; case : << + ; break; case + 1: << 2 * - ; break; default: << + ; break; }}} {(){=;=;switch( + ){ case : << - ; break; case : << + ; break; case : << * 2; break; case : << + ; break; case : << 2 * - ; break; default: << + ; break; }}} > Type: debug_output Hardness: 20 // 267 One case an integer variable, switch( * 5), Cases decrease by 5, A case matches, Cases assign int , output after switch # 267 Switch.Case.Case value is not a constant expression > [,,,]{(){=;=;=;switch( * 5){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 20 // --------------------------------------------------------------------------- // 300 // Switch.Body.No statement (has break) // 3 out of 6 cases with no statement but break - either evenly interspersed or back to back // Inc versus dec // print inSitu / update a variable and print at the end // Incrementing, inSitu printing, alternate even cases # 300 Switch.Body.No statement > [,]{(){=;switch(){ case : << - 1; break; case : break; case : << + 1; break; case : break; case : << ; break; case : break; default: << * 2; break; }}} > Type: debug_output Hardness: 30 // Incrementing, @end printing - variable update, back-to-back cases # 301 Switch.Body.No statement > [,]{(){=;=; switch(){ case : = + 1; break; case : = - 1; break; case : break; case : break; case : break; case : = + 10; break; default: = * 10; break; } << ; }} > Type: debug_output Hardness: 35 // Incrementing, @end printing - variable initialization, alternate odd cases # 302 Switch.Body.No statement > [,]{(){=;=0; switch(){ case : break; case : = ; break; case : break; case : = ; break; case : break; case : = ; break; default: = ; break; } << ; }} > Type: debug_output Hardness: 35 // Incrementing, inSitu printing, back-to-back cases # 303 Switch.Body.No statement > [,]{(){=; switch(){ case : break; case : break; case : break; case : << ; break; case : << + 1; break; case : << - 1; break; default: << + 10; break; } }} > Type: debug_output Hardness: 30 // Incrementing, @end printing - variable initialization- used to modify condition variable at the end, alternate even cases # 304 Switch.Body.No statement > [,]{(){=;=0; switch(){ case : = ; break; case : break; case : = ; break; case : break; case : = ; break; case : break; default: = - ; break; } = - ; << ; }} > Type: debug_output Hardness: 35 // Incrementing, @end printing - variable initialization- used to modify condition variable at the end, back-to-back # 305 Switch.Body.No statement > [,]{(){=;=0; switch(){ case : = ; break; case : break; case : break; case : break; case : = ; break; case : = 10; break; default: = ; break; } = + ; << ; }} > Type: debug_output Hardness: 30 // Decrementing, inSitu printing, alternate even cases # 310 Switch.Body.No statement > [,]{(){=;switch(){ case : break; case : << ; break; case : break; case : << ; break; case : break; case : << ; break; default: << ; break; }}} > Type: debug_output Hardness: 30 // Decrementing, @end printing - variable update, back-to-back cases # 311 Switch.Body.No statement > [,]{(){=;=; switch(){ case : = * 2; break; case : break; case : break; case : break; case : = / 2; break; case : = % 2; break; default: = + 2; break; } << ; }} > Type: debug_output Hardness: 35 // Decrementing, @end printing - variable initialization, alternate odd cases # 312 Switch.Body.No statement > [,]{(){=;=0; switch(){ case : = ; break; case : break; case : = ; break; case : break; case : = ; break; case : break; default: = ; break; } << ; }} > Type: debug_output Hardness: 35 // Decrementing, inSitu printing, back-to-back cases # 313 Switch.Body.No statement > [,]{(){=; switch(){ case : << - 1; break; case : << ; break; case : << + 1; break; case : break; case : break; case : break; default: << ; break; } }} > Type: debug_output Hardness: 30 // Decrementing, @end printing - variable initialization- used to modify condition variable at the end, alternate even cases # 314 Switch.Body.No statement > [,]{(){=;=0; switch(){ case : break; case : = ; break; case : break; case : = ; break; case : break; case : = ; break; default: = - ; break; } = - ; << ; }} > Type: debug_output Hardness: 35 // Decrementing, @end printing - variable initialization- used to modify condition variable at the end, back to back # 315 Switch.Body.No statement > [,]{(){=;=0; switch(){ case : = ; break; case : = 10; break; case : break; case : break; case : break; case : = ; break; default: = ; break; } = + ; << ; }} > Type: debug_output Hardness: 30 // --------------------------------------------------------------------------- // DONE // Since these are errors for C#, problem type is debug_output // 325 // Switch.Body.No break.Has statements // Incrementing vs Decrementing // Printing Vs Adding to a variable // THE FOLLOWING TEMPLATES ARE DESIGNED FOR PRIMARY USE BY C#. THEY HAVE EXACTLY ONE CASE WITH NO BREAK, AND THE CONDITION EVALUATES TO THAT CASE. // THEREFORE, THE TEMPLATES WILL WORK FOR C++ AND JAVA. BUT, SINCE THEY HAVE ONLY ONE CASE WITH NO BREAK, THEY WILL ALSO WORK FOR C# - REQUIRING // USER TO IDENTIFY ONLY ONE ERROR INSTEAD OF SAY 5 OR 6 ERRORS CORRESPONDING TO THE 5 OR 6 CASES WITH NO BREAK // 5 random values for cases # 325 Switch.Body.No break.Has statements > {(){=;switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; case : << ; break; default: << ; break; }}} > Type: debug_output Hardness: 30 # 326 Switch.Body.No break.Has statements > {(){=;switch(){ case : << + 10; break; case : << + 20; case : << - 10; break; case : << 100 - ; break; case : << - 20; break; default: << + ; break; }}} > Type: debug_output Hardness: 30 # 327 Switch.Body.No break.Has statements > {(){=;=;switch(){ case : << / ; break; case : << * ; break; case : << * ; break; case : << % ; break; case : << - ; default: << + ; break; }}} > Type: debug_output Hardness: 30 # 328 Switch.Body.No break.Has statements > {(){=;=;switch(){ case : = / ; break; case : = * ; break; case : = + 10; case : = * 10; break; case : = - ; break; default: = % ; break; } << ;}} > Type: debug_output Hardness: 30 # 329 Switch.Body.No break.Has statements > {(){ = 10;switch(){ case 10: << / 10; case 8: << * 10; break; case 6: << + ; break; case 4: << % 2; break; case 2: << * ; break; default: << % 10; break; }}} > Type: debug_output Hardness: 30 # 330 Switch.Body.No break.Has statements > []{(){ = 15; = ;switch(){ case 25: << / 10; break; case 20: << - ; break; case 15: << ; case 10: << ; break; case 5: << + ; break; default: << * ; break; }}} > Type: debug_output Hardness: 30 # 331 Switch.Body.No break.Has statements > []{(){ = ; = ;switch(){ case : << * 10; break; case : << * 10; break; case : << ; break; case : << * 100; case : << * 100; break; default: << ; break; }}} > Type: debug_output Hardness: 30 # 332 Switch.Body.No break.Has statements > {(){ = 70; = 100;switch(){ case 90: = / 10; break; case 80: = - 30; break; case 70: = ; case 60: = + 20; break; case 50: = * 2; break; default: = * 10; break; } << ;}} > Type: debug_output Hardness: 30 # 333 Switch.Body.No break.Has statements > []{(){ = ; = ;switch(){ case : << + 1; break; case : << + 1; case : << - 1; break; case : << - 1; break; case : << ; break; default: << ; break; }}} > Type: debug_output Hardness: 30 // THESE TEMPLATES ARE PREFERABLE FOR C++ AND JAVA. FOR C#, THEY GENERATE MULTIPLE ERRORS // Incrementing # 335 Switch.Body.No break.Has statements > // {(){=;switch(){ case 1: << * 10; case 2: << * 10; case 3: << * 10; case 4: << * 10; case 5: << * 10; default: << * 10; }}} [,,]{(){=;switch(){ case : << ; case : << ; case : << ; case : << ; case 5: << ; default: << ; }}} > Type: debug_output Hardness: 30 # 336 Switch.Body.No break.Has statements > // {(){=;switch(){ case 1: << ; break; case 2: << ; case 3: << ; case 4: << ; case 5: << ; break; default: << ; break; }}} [,]{(){=;switch(){ case : << - 2; break; case : << - 1; case : << ; case : << + 1; case : << + 2; break; default: << ; break; }}} > Type: debug_output Hardness: 35 # 337 Switch.Body.No break.Has statements > {(){=;=;switch(){ case 1: = - 1; case 2: = - 1; case 3: = - 1; case 4: = - 1; case 5: = - 1; default: = - 1; } << ; }} > Type: debug_output Hardness: 30 # 338 Switch.Body.No break.Has statements > {(){=;=;switch(){ case 1: = + 1; break; case 2: = + 1; case 3: = + 1; case 4: = + 1; case 5: = + 1; break; default: = + 1; break; } << ;}} > Type: debug_output Hardness: 35 # 339 Switch.Body.No break.Has statements > // {(){= * 10;=1;switch(){ case 10: = * 2; case 20: = * 2; case 30: = * 2; case 40: = * 2; case 50: = * 2; default: << ; } << ; }} []{(){=;=1;switch(){ case 10: = * 2; case 20: = * 2; case 30: = * 2; case 40: = * 2; case 50: = * 2; default: << ; } << ; }} > Type: debug_output Hardness: 35 # 340 Switch.Body.No break.Has statements > // {(){= * 10;=0;switch(){ case 10: = + 10; break; case 20: = + 10; case 30: = + 10; case 40: = + 10; case 50: = + 10; break; default: << ; break; } << ;}} [,]{(){=;=;switch(){ case 10: = + 10; break; case 20: = + 10; case 30: = + 10; case 40: = + 10; case 50: = + 10; break; default: << ; break; } << ;}} > Type: debug_output Hardness: 35 // Decrementing # 344 Switch.Body.No break.Has statements > // {(){=;switch(){ case 5: << * 10; case 4: << * 10; case 3: << * 10; case 2: << * 10; case 1: << * 10; default: << * 10; }}} [,,,,,]{(){=;switch(){ case 5: << ; case 4: << ; case 3: << ; case 2: << ; case 1: << ; default: << ; }}} > Type: debug_output Hardness: 30 # 345 Switch.Body.No break.Has statements > {(){=;switch(){ case 5: << + 10; break; case 4: << + 1; case 3: << ; case 2: << - 1; case 1: << * 10; break; default: << ; break; }}} > Type: debug_output Hardness: 35 # 346 Switch.Body.No break.Has statements > {(){=;=0;switch(){ case 5: = + 2; case 4: = + 2; case 3: = + 2; case 2: = + 2; case 1: = + 2; default: = + 2; } << ; }} > Type: debug_output Hardness: 30 # 347 Switch.Body.No break.Has statements > // {(){=;=10;switch(){ case 5: = - 2; break; case 4: = - 2; case 3: = - 2; case 2: = - 2; case 1: = - 2; break; default: = - 2; break; } << ;}} [,,]{(){=;=;switch(){ case 5: = - 2; break; case 4: = - 2; case 3: = - 2; case 2: = - 2; case 1: = - 2; break; default: = - 2; break; } << ;}} > Type: debug_output Hardness: 35 # 348 Switch.Body.No break.Has statements > // {(){= * 10;=16;switch(){ case 50: = / 2; case 40: = / 2; case 30: = / 2; case 20: = / 2; case 10: = / 2; default: << ; } << ; }} [,]{(){=;=;switch(){ case 50: = / 2; case 40: = / 2; case 30: = / 2; case 20: = / 2; case 10: = / 2; default: << ; } << ; }} > Type: debug_output Hardness: 35 # 349 Switch.Body.No break.Has statements > // {(){= * 10;=50;switch(){ case 50: = - 10; break; case 40: = - 10; case 30: = - 10; case 20: = - 10; case 10: = - 10; break; default: << ; break; } << ;}} [,]{(){=;=;switch(){ case 50: = - 10; break; case 40: = - 10; case 30: = - 10; case 20: = - 10; case 10: = - 10; break; default: << ; break; } << ;}} > Type: debug_output Hardness: 35 // --------------------------------------------------------------------------- // 350 // Switch.Body.No break.No statement // DONE // Incrementing # 350 Switch.Body.No break.No statement > // {(){= * 10; = + ;switch(){ case 16: case 17: case 18: case 19: case 20: << ; break; case 26: case 27: case 28: case 29: case 30: << ; break; case 36: case 37: case 38: case 39: case 40: << ; break; default: << ; break; }}} [,]{(){=;switch(){ case 16: case 17: case 18: case 19: case 20: << ; break; case 26: case 27: case 28: case 29: case 30: << ; break; case 36: case 37: case 38: case 39: case 40: << ; break; default: << ; break; }}} > Type: debug_output Hardness: 30 # 351 Switch.Body.No break.No statement > // {(){= * 10; = + ;switch(){ case 41: case 42: case 43: case 44: case 45: << / 10; break; case 51: case 52: case 53: case 54: case 55: << * 10; break; case 61: case 62: case 63: case 64: case 65: << + ; break; default: << - ; break; }}} [,]{(){=; = ;switch(){ case 41: case 42: case 43: case 44: case 45: << / 10; break; case 51: case 52: case 53: case 54: case 55: << * 10; break; case 61: case 62: case 63: case 64: case 65: << + ; break; default: << - ; break; }}} > Type: debug_output Hardness: 30 # 352 Switch.Body.No break.No statement > // {(){= * 10; = + ;=;switch(){ case 11: case 12: case 13: case 14: case 15: = + 10; break; case 21: case 22: case 23: case 24: case 25: = * 10; break; case 31: case 32: case 33: case 34: case 35: = + 1; break; default: = * 2; break; } << ; }} [,]{(){=;=;switch(){ case 11: case 12: case 13: case 14: case 15: = + 10; break; case 21: case 22: case 23: case 24: case 25: = * 10; break; case 31: case 32: case 33: case 34: case 35: = + 1; break; default: = * 2; break; } << ; }} > Type: debug_output Hardness: 30 # 353 Switch.Body.No break.No statement > // {(){= * 10; = + ;;switch(){ case 74: case 75: case 76: case 77: case 78: = ; break; case 84: case 85: case 86: case 87: case 88: = * 10; break; case 94: case 95: case 96: case 97: case 98: = * 10; break; default: = * 10; break; } << ;}} [,,,]{(){= ; = ;;switch(){ case 74: case 75: case 76: case 77: case 78: = ; break; case 84: case 85: case 86: case 87: case 88: = * 10; break; case 94: case 95: case 96: case 97: case 98: = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 30 # 354 Switch.Body.No break.No statement > // {(){= * 2; = * 10; = + ;switch(){ case 42: case 44: case 46: case 48: case 50: << ; break; case 52: case 54: case 56: case 58: case 60: << ; break; case 62: case 64: case 66: case 68: case 70: << + ; break; default: << ; break; }}} [,]{(){= ; = ; = + ;switch(){ case 42: case 44: case 46: case 48: case 50: << ; break; case 52: case 54: case 56: case 58: case 60: << ; break; case 62: case 64: case 66: case 68: case 70: << ; break; default: << ; break; }}} > Type: debug_output Hardness: 30 # 355 Switch.Body.No break.No statement > // {(){= * 10; = * 100; = + ;;switch(){ case 150: case 160: case 170: case 180: case 190: = * 100; break; case 250: case 260: case 270: case 280: case 290: = ; break; case 350: case 360: case 370: case 380: case 390: = * 10; break; default: = ; break; } << ;}} [,,]{(){= ; = ; = + ;;switch(){ case 150: case 160: case 170: case 180: case 190: = ; break; case 250: case 260: case 270: case 280: case 290: = ; break; case 350: case 360: case 370: case 380: case 390: = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 30 // Decrementing # 360 Switch.Body.No break.No statement > [,]{(){= ;switch(){ case 69: case 68: case 67: case 66: case 65: << ; break; case 59: case 58: case 57: case 56: case 55: << ; break; case 49: case 48: case 47: case 46: case 45: << ; break; default: << ; break; }}} > Type: debug_output Hardness: 30 # 361 Switch.Body.No break.No statement > // []{(){=; = + ;switch(){ case 95: case 94: case 93: case 92: case 91: << + 10; break; case 85: case 84: case 83: case 82: case 81: << + 10; break; case 75: case 74: case 73: case 72: case 71: << - 10; break; default: << - 10; break; }}} [,,,]{(){=; = ;switch(){ case 95: case 94: case 93: case 92: case 91: << + 10; break; case 85: case 84: case 83: case 82: case 81: << + 10; break; case 75: case 74: case 73: case 72: case 71: << - 10; break; default: << - 10; break; }}} > Type: debug_output Hardness: 30 # 362 Switch.Body.No break.No statement > [,]{(){= ;=;switch(){ case 38: case 37: case 36: case 35: case 34: = * 10; break; case 28: case 27: case 26: case 25: case 24: = + 10; break; case 18: case 17: case 16: case 15: case 14: = + 2; break; default: = - 2; break; } << ; }} > Type: debug_output Hardness: 30 # 363 Switch.Body.No break.No statement > [,,,]{(){=;;switch(){ case 99: case 98: case 97: case 96: case 95: = ; break; case 89: case 88: case 87: case 86: case 85: = ; break; case 79: case 78: case 77: case 76: case 75: = ; break; default: = ; break; } << ;}} > Type: debug_output Hardness: 30 # 364 Switch.Body.No break.No statement > // [,]{(){= ; = ; = + ;switch(){ case 98: case 96: case 94: case 92: case 90: << ; break; case 88: case 86: case 84: case 82: case 80: << ; break; case 78: case 76: case 74: case 72: case 70: << - ; break; default: << ; break; }}} [,,,,]{(){= ; = ; = ;switch(){ case 98: case 96: case 94: case 92: case 90: << ; break; case 88: case 86: case 84: case 82: case 80: << ; break; case 78: case 76: case 74: case 72: case 70: << - ; break; default: << ; break; }}} > Type: debug_output Hardness: 30 # 365 Switch.Body.No break.No statement > // [,]{(){=; = ; = + ;;switch(){ case 650: case 640: case 630: case 620: case 610: = * 100; break; case 550: case 540: case 530: case 520: case 510: = ; break; case 450: case 440: case 430: case 420: case 410: = * 100; break; default: = 1000; break; } << ;}} [,,,,]{(){=; = ; = ;;switch(){ case 650: case 640: case 630: case 620: case 610: = * 100; break; case 550: case 540: case 530: case 520: case 510: = ; break; case 450: case 440: case 430: case 420: case 410: = * 100; break; default: = 1000; break; } << ;}} > Type: debug_output Hardness: 30 // --------------------------------------------------------------------------- // 400 // Switch.Nested // Considered incrementing versus decrementing // Printing in-situ versus printing at the end of the nested switch versus printing at the end of the nesting switch (much harder, must ensure uniqueness of all 9 cases) // inc-inc/in-situ/var - 400 // /end-of-nested/var - 401 // /in-situ/expr - 402 // /@ end/expr - 403 // /in-situ/expr - 404 // /end-of-nested/expr with multiples of 100 - 405 // Incrementing # 400 Switch.Nested > {(){=;=;=;switch(){ case 1: switch(){ case 4: << ; break; case 5: << ; break; case 6: << ; break; default: << ; << ; break; } break; case 2: switch(){ case 7: << ; break; case 8: << ; break; case 9: << ; break; default: << ; << ; break; } break; case 3: switch(){ case 4: << ; break; case 5: << ; break; case 6: << ; break; default: << ; << ; break; } break; default: << ; << ; << ; break; }}} > Type: output Hardness: 50 # 401 Switch.Nested > {(){=;=;=;;switch(){ case 4: switch(){ case 1: = ; break; case 2: = ; break; case 3: = ; break; default: = ; break; } << ; break; case 5: switch(){ case 7: = ; break; case 8: = ; break; case 9: = ; break; default: = ; break; } << ; break; case 6: switch(){ case 1: = ; break; case 2: = ; break; case 3: = ; break; default: = ; break; } << ; break; default: << ; << ; << ; break; }}} > Type: output Hardness: 50 # 402 Switch.Nested > {(){=;=;=;switch(){ case 1: switch(){ case 4: << + ; break; case 5: << + ; break; case 6: << + ; break; default: << ; << ; break; } break; case 2: switch(){ case 4: << - ; break; case 5: << - ; break; case 6: << - ; break; default: << ; << ; break; } break; case 3: switch(){ case 7: << - ; break; case 8: << - ; break; case 9: << - ; break; default: << ; << ; break; } break; default: << ; << ; << ; break; }}} > Type: output Hardness: 50 # 403 Switch.Nested > []{(){=;;;switch(){ case 70: = ; switch(){ case 1: = * 10; break; case 2: = + 10; break; case 3: = ; break; default: = ; break; } break; case 80: = ; switch(){ case 7: = + 10; break; case 8: = ; break; case 9: = * 10; break; default: = ; break; } break; case 90: = ; switch(){ case 4: = ; break; case 5: = * 10; break; case 6: = + 10; break; default: = ; break; } break; default: = ; break; } << ; }} > Type: output Hardness: 50 # 404 Switch.Nested > []{(){=;;switch(){ case 10: = ; switch(){ case 1: << + ; break; case 2: << / ; break; case 3: << - ; break; default: << * 10; break; } break; case 20: = ; switch(){ case 4: << / ; break; case 5: << + ; break; case 6: << - ; break; default: << ; << ; break; } break; case 30: = ; switch(){ case 7: << ; break; case 8: << + ; break; case 9: << - ; break; default: << ; << ; break; } break; default: << ; << * 10; break; }}} > Type: output Hardness: 50 # 405 Switch.Nested > [,,,]{(){=;;;switch(){ case 400: = ; switch(){ case 70: = / 10; break; case 80: = ; break; case 90: = / 10; break; default: = ; break; } << ; break; case 500: = ; switch(){ case 40: = / 10; break; case 50: = / ; break; case 60: = / 10; break; default: = ; break; } << ; break; case 600: = ; switch(){ case 10: = / 10; break; case 20: = / ; break; case 30: = / 10; break; default: = ; break; } << ; break; default: << ; << ; break; }}} > Type: output Hardness: 50 // Decrementing # 410 Switch.Nested > {(){=;=;=;switch(){ case 6: switch(){ case 3: << ; break; case 2: << ; break; case 1: << ; break; default: << ; << ; break; } break; case 5: switch(){ case 9: << ; break; case 8: << ; break; case 7: << ; break; default: << ; << ; break; } break; case 4: switch(){ case 3: << ; break; case 2: << ; break; case 1: << ; break; default: << ; << ; break; } break; default: << ; << ; << ; break; }}} > Type: output Hardness: 50 # 411 Switch.Nested > {(){=;=;=;;switch(){ case 9: switch(){ case 3: = ; break; case 2: = ; break; case 1: = ; break; default: = ; break; } << ; break; case 8: switch(){ case 6: = ; break; case 5: = ; break; case 4: = ; break; default: = ; break; } << ; break; case 7: switch(){ case 6: = ; break; case 5: = ; break; case 4: = ; break; default: = ; break; } << ; break; default: << ; << ; << ; break; }}} > Type: output Hardness: 50 # 412 Switch.Nested > {(){=;=;=;switch(){ case 9: switch(){ case 6: << / 3; break; case 5: << - ; break; case 4: << / 2; break; default: << ; << ; break; } break; case 8: switch(){ case 6: << / 4; break; case 5: << - ; break; case 4: << / 2; break; default: << ; << ; break; } break; case 7: switch(){ case 3: << + ; break; case 2: << * ; break; case 1: << - ; break; default: << ; << ; break; } break; default: << ; << ; << ; break; }}} > Type: output Hardness: 50 # 413 Switch.Nested > []{(){=;;;switch(){ case 90: = ; switch(){ case 6: = + 10; break; case 5: = * 10; break; case 4: = ; break; default: = ; break; } break; case 80: = ; switch(){ case 9: = ; break; case 8: = + 10; break; case 7: = * 10; break; default: = ; break; } break; case 70: = ; switch(){ case 3: = * 10; break; case 2: = ; break; case 1: = + 10; break; default: = ; break; } break; default: = ; break; } << ; }} > Type: output Hardness: 50 # 414 Switch.Nested > []{(){=;;switch(){ case 30: = ; switch(){ case 9: << / 10; break; case 8: << / 2; break; case 7: << ; break; default: << * 10; break; } break; case 20: = ; switch(){ case 6: << / 2; break; case 5: << + ; break; case 4: << / 10; break; default: << * 10; break; } break; case 10: = ; switch(){ case 3: << - ; break; case 2: << / ; break; case 1: << + ; break; default: << * 10; break; } break; default: << ; << ; break; }}} > Type: output Hardness: 50 # 415 Switch.Nested > [,,,]{(){=;;;switch(){ case 600: = ; switch(){ case 30: = / 100; break; case 20: = / 10; break; case 10: = / ; break; default: = ; break; } << ; break; case 500: = ; switch(){ case 60: = / 10; break; case 50: = / ; break; case 40: = / 10; break; default: = ; break; } << ; break; case 400: = ; switch(){ case 90: = / 10; break; case 80: = + ; break; case 70: = / 10; break; default: = ; break; } << ; break; default: << ; << ; break; }}} > Type: output Hardness: 50 // --------------------------------------------------------------------------- // Multiple switches // Incrementing versus decrementing: ii, id, di, dd // independent versus dependent: pp, vp, vv (after each switch versus at the end, one variable versus two) // assign to variable in first, use it as condition of second to print // assign to variable in first, use it as condition of second to assign to another variable and print it after second switch // Modify value of same variable in both switch statements, and print after second switch // inc-inc, inc-dec, dec-inc, dec-dec // // inc-inc, @end-@end (m + n and m - n) # 500 Switch.Multiple > [,]{(){=; = ;;switch(){ case : = ; break; case : = ; break; case : = + 1; break; case : = - 1; break; case : = ; break; default: = ; break;} << ; switch(){ case : = + 10; break; case : = + 1; break; case : = - 1; break; case : = * 10; break; case : = - 10; break; default: = 0; break;} << ; }} > Type: output Hardness: 40 // inc-dec, inSitu-@end (m + 2n and m - 2n) # 501 Switch.Multiple > [,]{(){=; = ;switch(){ case : << ; break; case : << ; break; case : << + 2; break; case : << - 2; break; case : << ; break; default: << ; break;} ; switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break;} << ; }} > Type: output Hardness: 40 // dec-inc, @end-inSitu (m - 2n, and its multiples of 10) # 502 Switch.Multiple > [,]{(){=; = ;;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = 0; break;} << ; switch(){ case : << ; break; case : << + 1; break; case : << - 1; break; case : << + 2; break; case : << - 2; break; default: << * 2; break;} }} > Type: output Hardness: 40 // dec-dec, inSitu-inSitu (Multiples of 100 and 10) # 503 Switch.Multiple > [,]{(){=; = ;switch(){ case 1000: << ; break; case 900: << ; break; case 800: << / 100; break; case 700: << / 10; break; case 600: << / 10; break; default: << ; << ; break;} switch(){ case 50: << + 10; break; case 40: << - 10; break; case 30: << * 10; break; case 20: << + ; break; case 10: << / ; break; default: << ; << ; break;} }} > Type: output Hardness: 40 // inc-inc, inSitu-@end (Multiples of 3 and 2) # 504 Switch.Multiple > // [,,]{(){=; = ;switch(){ case : << * 10; break; case : << * 10; break; case : << + 10; break; case : << + 10; break; case : << + 100; break; default: << + 100; break;} ; switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break;} << ; }} [,,]{(){=; = ; =;switch(){ case : << * 10; break; case : << * 10; break; case : << + 10; break; case : << + 10; break; case : << + 100; break; default: << + 100; break;} switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break;} << ; }} > Type: output Hardness: 40 // inc-dec, @end-@end (multiples of 5 and 10) # 505 Switch.Multiple > [,,]{(){=; = ;;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = * 10; break;} << ; switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = * 5; break;} << ; }} > Type: output Hardness: 40 // dec-inc, inSitu-inSitu (odd, even) # 506 Switch.Multiple > [,,]{(){=; = ; switch(){ case : << - 1; break; case : << + 1; break; case : << ; break; case : << - 1; break; case : << + 1; break; default: << ; break;} switch(){ case : << + 2; break; case : << - 2; break; case : << ; break; case : << + 2; break; case : << - 2; break; default: << ; break;} }} > Type: output Hardness: 40 // dec-dec, @end-inSitu (10m + 10n, 10m - 10n) # 507 Switch.Multiple > [,]{(){=; = ; ; switch(){ case : = / 10; break; case : = * 10; break; case : = - 10; break; case : = + 10; break; case : = + 100; break; default: = ; break;} << ; switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << * 10; break;} }} > Type: output Hardness: 40 // Dependent switches // [,]{(){=;;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break;} << ; ; switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break;} << ; }} // [,]{(){=;;switch(){ case : = ; break; case : = ; break; case : = ; break; case : = ; break; case : = ; break; default: = ; break;} << ; switch(){ case : << ; break; case : << ; break; case : << ; break; case : << ; break; case : << ; break; default: << ; break;} }} // // FOLLOWING DOES NOT WORK IF VALUE OF CONDITION IS 2 OR GREATER - BUG TO BE FIXED - // // BLOCK INSIDE A STATEMENTSEQUENCE SEEMS TO GENERATE A PROBLEM // # 600 // Switch.Condition.Matches case // > // // {(){=;switch(){ case 1: << ; break; case 2: << ; break; case 3: << ; break; case 4: << ; break; case 5: << ; break; default: << ; break; }}} // {(){=2;switch(){ case 1: {<< ; break;} case 2: {<< ;} break; case 3: {<< ;} << ; break; case 4: {<< ;} << ; {<< ;} break; case 5: << ; break; default: << ; break; }}} // > // Type: debug_output // Hardness: 20 // ------------------ Parsons Puzzles -------------------------------------------------------- // DESIGN PRINCIPLES: // At least 3 cases - otherwise, if-else would suffice // Discrete cases, not ranges - nested if-else better for the latter // Learning objectives: // Switch.Parsons.Single.Statements - 2000 // Execution of a single switch statement // Switch.Parsons.Single.Empty - 2025 // Execution of a single switch statement with break skipped in some cases // Switch.Parsons.Multiple.Statements - 2050 // Execution of multiple switch statements // Switch.Parsons.Multiple.Empty - 2075 // Execution of multiple switch statements with break skipped in some cases // Switch.Parsons.Nested.Statements - 2100 // Execution of nested switch statements // Switch.Parsons.Nested.Empty - 2125 // Execution of nested switch statements with break skipped in some cases // -------------------------------------------------------------------------------------------- // Switch.Parsons.Single.Statements - 2000 // EMPHASIZE MUST SOLVE IN ORDER PROVIDED - ALWAYS // 4 // prints first 9 numbers with suffix, 4 through 9 being default # 2000 Switch.Parsons.Single.Statements > "It reads a number (1-9) and prints it with suffix, as in 1st, 2nd, 3rd or 4th." {(){ /* Declare */ ; /* Read */ << "Enter a number (1-9)"; >> ; /* Print the number */ << ; /* Compute and print the suffix */ /* --- Use ascending order: 1, 2, 3 and the rest */ switch( ) { case 1: << "st"; break; case 2: << "nd"; break; case 3: << "rd"; break; default: << "th"; break; }}} > Type: parsons Hardness: 20 // DemoParsons // 4 // prints the name of the coin # 2001 Switch.Parsons.Single.Statements > "It reads the value of a coin (25/10/5/1) and prints its name (quarter/dime/nickel/penny)." {(){ /* Declare */ ; /* Read */ << "Enter the value of the coin (25/10/5/1)"; >> ; /* Compute the print the coin's name */ /* --- Use descending order: 25, 10, 5 and 1 */ switch( ) { case 25: << "quarter"; break; case 10: << "dime"; break; case 5: << "nickel"; break; case 1: << "penny"; break; }}} > Type: parsons Hardness: 20 // 5 // car rental: economy, midsize, luxury, suv, truck # 2002 Switch.Parsons.Single.Statements > "It reads the type of rental car as a character (e for economy, l for luxury, m for mid-size, s for SUV and t for truck) and prints its name as a string (economy/luxury...)." {(){ /* Declare */ ; /* Read */ << "Enter the type of rental car (e/l/m/s/t)"; >> ; /* Compute the print the name of the rental car */ /* --- Use alphabetical order: e, l, m, s, and t */ switch( ) { case 'e': << "You picked Economy car"; break; case 'l': << "You picked Luxury car"; break; case 'm': << "You picked Mid-size car"; break; case 's': << "You picked SUV"; break; case 't': << "You picked Truck"; break; default: << "Your input of rental car is invalid"; break; }}} > Type: parsons Hardness: 20 // 5 // type of lighting: incandescent, fluorescent, halogen, led, neon # 2003 Switch.Parsons.Single.Statements > "It reads the type of lighting as a character (f for fluorescent, h for halogen, i for incandescent, l for LED and n for neon) and prints its name as a string (fluorescent/halogen/...)." {(){ /* Declare */ ; /* Read */ << "Enter the type of lighting (f/h/i/l/n)"; >> ; /* Compute the print the name of the lighting */ /* --- Use alphabetical order: f, h, i, l, and n */ switch( ) { case 'f': << "You selected Fluorescent lighting"; break; case 'h': << "You selected Halogen lighting"; break; case 'i': << "You selected Incandescent lighting"; break; case 'l': << "You selected LED lighting"; break; case 'n': << "You selected Neon lighting"; break; default: << "Your input of lighting type is invalid"; break; }}} > Type: parsons Hardness: 20 // 5 // Given the symbol, print the name of the operation: addition, subtraction.. // OR period, exclamation point, question mark, etc. # 2004 Switch.Parsons.Single.Statements > "It reads the symbol of an arithmetic operator (+,-,*,/,%) and prints the name of the operation (addition/subtraction...)." {(){ /* Declare */ ; /* Read */ << "Enter the symbol of the arithmetic operator (+,-,*,/,%)"; >> ; /* Compute the print the name of the arithmetic operation */ /* --- Use the order: addition, subtraction, multiplication, division and remainder */ switch( ) { case '+': << "You selected Addition"; break; case '-': << "You selected Subtraction"; break; case '*': << "You selected Multiplication"; break; case '/': << "You selected Division"; break; case '%': << "You selected Remainder"; break; default: << "Your input of arithmetic operator symbol is invalid"; break; }}} > Type: parsons Hardness: 20 // Pretest // 7 // Roman numerals: V X L C D M # 2010 Switch.Parsons.Single.Statements > "It reads a roman numeral and prints the corresponding number: V is 5, X is 10, L is 50, C is 100, D is 500 and M is 1000." {(){ /* Declare */ ; /* Read */ << "Enter the roman numeral as character: V/X/L/C/D/M"; >> ; /* Compute and print the number corresponding to */ /* --- Use the order: V X L C D M */ switch( ) { case 'V': << "V is 5"; break; case 'X': << "X is 10"; break; case 'L': << "L is 50"; break; case 'C': << "C is 100"; break; case 'D': << "D is 500"; break; case 'M': << "M is 1000"; break; default: << "Your roman numeral entry is invalid"; break; }}} > Type: parsons Hardness: 30 // Posttest // 7 // Algebraic chess notation // chess pieces: King, Queen, kNight, Bishop, Rook, Pawn # 2011 Switch.Parsons.Single.Statements > "It reads a chess piece in algebraic chess notation as a character (b for Bishop, k for King, n for Knight, p for Pawn, q for Queen and r for Rook) and prints the name of the piece (Bishop/King/...)." {(){ /* Declare */ ; /* Read */ << "Enter the algebraic notation of the chess piece (b/k/n/p/q/r)"; >> ; /* Compute the print the name of the chess piece */ /* --- Use alphabetical order: b, k, n, p, q, and r */ switch( ) { case 'b': << "Bishop"; break; case 'k': << "King"; break; case 'n': << "kNight"; break; case 'p': << "Pawn"; break; case 'q': << "Queen"; break; case 'r': << "Rook"; break; default: << "Your input of chess piece is invalid"; break; }}} > Type: parsons Hardness: 30 // 8 // 1: POLYETHYLENE TEREPHTHALATE (PET OR PETE) (2 lts soda bottles, single-use water bottles // 2: HIGH DENSITY POLYETHYLENE (HDPE) (milk jugs, detergent bottles, yogurt tub, bottle cap // 3: POLYVINYL CHLORIDE (PVC): house siding, pipes, saran wrap, outdoor furniture // 4: LOW DENSITY POLYETHYLENE (LDPE): grocery bags, trash can liners, food storage containers // 5: POLYPROPYLENE (PP): bottle caps, food containers, drinking straws // 6: POLYSTYRENE (PS): styrofoam peanuts, clam shell containers, meat trays, plastic tableware // 7: OTHER: Tupperware # 2012 Switch.Parsons.Single.Statements > "It reads the type of plastic as a number (1-7) and prints the name of the plastic (e.g., Type 3 is PVC)." {(){ /* Declare */ ; /* Read */ << "Enter the type of plastic (1-7)"; >> ; /* Compute the print the name of the plastic */ /* --- Use ascending order of the value of */ switch( ) { case 1: << "Type 1 is PET"; break; case 2: << "Type 2 is HDPE"; break; case 3: << "Type 3 is PVC"; break; case 4: << "Type 4 is LDPE"; break; case 5: << "Type 5 is PP"; break; case 6: << "Type 6 is PS"; break; case 7: << "Type 7 is OTHER"; break; default: << "Your input of the type of plastic is invalid"; break; }}} > Type: parsons Hardness: 30 // variable number of cases // Name of the currency e-euro, d-dollar, rupees, reals, // 4 // p/n/f/b: x or y incremented or decremented // Problem - must also read x and y coords // 5 // Print the names of the weekdays: 1 is Monday through 5 is Friday // 4-5 // calculator // Must also read operands // 10 // Prints a number in spanish // cero uno dos tres cuatro cinco seis siete ocho nueve # 2015 Switch.Parsons.Single.Statements > "It reads a number (0-9) and prints it in Spanish." {(){ /* Declare */ ; /* Read */ << "Enter the number (0-9)"; >> ; /* Compute the print the number in Spanish */ /* --- Use ascending order of the value of */ switch( ) { case 0: << "0 is Cero"; break; case 1: << "1 is Uno"; break; case 2: << "2 is Dos"; break; case 3: << "3 is Tres"; break; case 4: << "4 is Cuatro"; break; case 5: << "5 is Cinco"; break; case 6: << "6 is Seis"; break; case 7: << "7 is Siete"; break; case 8: << "8 is Ocho"; break; case 9: << "9 is Nueve"; break; }}} > Type: parsons Hardness: 30 // 10 // leetspeak: 0-0, 1-l, 3-e.. // a - 4, b - 6, e - 3, g - 9, i - 1, o - 0, s - 5, t - 7, r - 2 # 2016 Switch.Parsons.Single.Statements > "It reads an alphabetic character and returns its substitute number in leetspeak which looks most like it." {(){ /* Declare */ ; /* Read */ << "Enter the alphabetic character"; >> ; /* Compute the print the corresponding number in leetspeak */ /* --- Use ascending order of the value of */ switch( ) { case 'a': << "Use 4 for a"; break; case 'b': << "Use 6 for b"; break; case 'e': << "Use 3 for e"; break; case 'g': << "Use 9 for g"; break; case 'i': << "Use 1 for i"; break; case 'o': << "Use 0 for o"; break; case 'r': << "Use 2 for r"; break; case 's': << "Use 5 for s"; break; case 't': << "Use 7 for t"; break; default: << "There is no number in leetspeak for the character you entered"; break; }}} > Type: parsons Hardness: 30 // 10 // Prints a number in french // zero un deux trois quatre cinq six sept huit neuf # 2017 Switch.Parsons.Single.Statements > "It reads a number (0-9) and prints it in French." {(){ /* Declare */ ; /* Read */ << "Enter the number (0-9)"; >> ; /* Compute the print the number in French */ /* --- Use ascending order of the value of */ switch( ) { case 0: << "0 is Zero"; break; case 1: << "1 is Un"; break; case 2: << "2 is Deux"; break; case 3: << "3 is Trois"; break; case 4: << "4 is Quatre"; break; case 5: << "5 is Cinq"; break; case 6: << "6 is Six"; break; case 7: << "7 is Sept"; break; case 8: << "8 is Huit"; break; case 9: << "9 is Neuf"; break; }}} > Type: parsons Hardness: 30 // 10 // Prints the morse code for the ten digits # 2018 Switch.Parsons.Single.Statements > "It reads a number (0-9) and prints the corresponding Morse code." {(){ /* Declare */ ; /* Read */ << "Enter the number (0-9)"; >> ; /* Compute the print the corresponding Morse code */ /* --- Use ascending order of the value of */ switch( ) { case 0: << "0 is - - - - -"; break; case 1: << "1 is . - - - -"; break; case 2: << "2 is . . - - -"; break; case 3: << "3 is . . . - -"; break; case 4: << "4 is . . . . -"; break; case 5: << "5 is . . . . ."; break; case 6: << "6 is - . . . ."; break; case 7: << "7 is - - . . ."; break; case 8: << "8 is - - - . ."; break; case 9: << "9 is - - - - ."; break; }}} > Type: parsons Hardness: 30 // 12 // prints the name of the month # 2019 Switch.Parsons.Single.Statements > "It reads the number of a month (1-12) and prints the name of the month (January - December)." {(){ /* Declare */ ; /* Read */ << "Enter the number of the month (1-12)"; >> ; /* Compute and print the name of the month */ /* --- Use ascending order: 1 through 12 */ switch( ) { case 1: << "January"; break; case 2: << "February"; break; case 3: << "March"; break; case 4: << "April"; break; case 5: << "May"; break; case 6: << "June"; break; case 7: << "July"; break; case 8: << "August"; break; case 9: << "September"; break; case 10: << "October"; break; case 11: << "November"; break; case 12: << "December"; break; default: << "Your month input is invalid"; break; }}} > Type: parsons Hardness: 30 // 26 // prints call signs - alpha, bravo, charlie, delta # 2020 Switch.Parsons.Single.Statements > "It reads an alphabetic character and prints the corresponding phonetic alphabet (e.g., Alpha for A, Bravo for B)." {(){ /* Declare */ ; /* Read */ << "Enter the alphabetic character"; >> ; /* Compute the print the corresponding phonetic alphabet */ /* --- Use alphabetic order of the value of */ switch( ) { case 'A': << "Alpha"; break; case 'B': << "Bravo"; break; case 'C': << "Charlie"; break; case 'D': << "Delta"; break; case 'E': << "Echo"; break; case 'F': << "Foxtrot"; break; case 'G': << "Golf"; break; case 'H': << "Hotel"; break; case 'I': << "India"; break; case 'J': << "Juliett"; break; case 'K': << "Kilo"; break; case 'L': << "Lima"; break; case 'M': << "Mike"; break; case 'N': << "November"; break; case 'O': << "Oscar"; break; case 'P': << "Papa"; break; case 'Q': << "Quebec"; break; case 'R': << "Romeo"; break; case 'S': << "Sierra"; break; case 'T': << "Tango"; break; case 'U': << "Uniform"; break; case 'V': << "Victor"; break; case 'W': << "Whiskey"; break; case 'X': << "Xray"; break; case 'Y': << "Yankee"; break; case 'Z': << "Zulu"; break; }}} > Type: parsons Hardness: 30 // 6 // Single, multiple statements per case // Reads greenwich time and time zone, prints corresponding time in that time zone // eastern/central/mountain/pacific/alaskan (-1)/hawaiian (-2)/Samoan/Chamorro // 10 // A1, A2, A3, A4 paper size // Polygon based on number of sides // triangle, quadrilateral, penetagon, hexagon, heptagon, octagon, nonagon, decagon, hendecagon, dodecagon // mono, di tri, tetra, penta, hexa, hepta, octa, ennea, deca, hendeca - chemical prefixes // base 2 - binary, 8 octal, 10 decimal and 16 hexadecimal // operator - unary, binary, ternary // Greek alphabet - alpha, beta, gamma, delta. // -------------------------------------------------------------------------------------------- // Switch.Parsons.Single.Empty - 2025 // 8 cases - 4 groups // Suffix for any day of the month # 2025 Switch.Parsons.Single.Empty > "It reads the day (1-31) and prints it with appropriate suffix (e.g., 1st, 2nd, 13th)." {(){ /* Declare */ ; /* Read */ << "Enter the day (1-31)"; >> ; /* Print the day */ << ; /* Compute and print the suffix */ /* --- Handle suffixes in the order: "st", "nd", "rd", "th" */ /* ----- For each suffix, list the days in increasing order */ switch( ) { case 1: case 21: case 31: << "st"; break; case 2: case 22: << "nd"; break; case 3: case 23: << "rd"; break; default: << "th"; break; }}} > Type: parsons Hardness: 20 // 11 cases - 2 groups // vowels and consonants # 2026 Switch.Parsons.Single.Empty > "It reads an alphabetic character and prints whether it is a vowel (a/A/e/E/i/I/o/O/u/U) or consonant." {(){ /* Declare */ ; /* Read */ << "Enter the alphabetic character (a-z,A-Z)"; >> ; /* Compute and print whether is a vowel or consonant */ /* --- Use the order: a, A, e, E, i, I, o, O, u, U */ switch( ) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': << << " is a vowel"; break; default: << << " is a consonant"; break; }}} > Type: parsons Hardness: 20 // DemoParsons // 13 cases - 4 groups // Number of days given month in a non-leap year # 2027 Switch.Parsons.Single.Empty > "It reads the month (1 for January - 12 for December) and prints the number of days in the month (e.g., 31 for January)." {(){ /* Declare */ ; /* Read */ << "Enter the month as a number (1-12)"; >> ; /* Compute and print the number of days in the month */ /* --- List months in increasing order for 31 days, 30 days, and February */ switch( ) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: << "Months 1,3,5,7,8,10,12 have 31 days"; break; case 4: case 6: case 9: case 11: << "Months 4,6,9,11 have 30 days"; break; case 2: << "February has 28 or 29 days"; break; default: << "Your month input is invalid"; break; }}} > Type: parsons Hardness: 20 // pretest // 13 cases - 5 groups // Season given month # 2028 Switch.Parsons.Single.Empty > "It reads the month (1 for January - 12 for December) and prints the corresponding season." {(){ /* Declare */ ; /* Read */ << "Enter the month as a number (1-12)"; >> ; /* Compute and print the season of the month */ /* --- Use increasing order of months - 1 through 12 */ switch( ) { case 1: case 2: case 3: << "January - March is Winter"; break; case 4: case 5: case 6: << "April - June is Spring"; break; case 7: case 8: case 9: << "July - September is Summer"; break; case 10: case 11: case 12: << "October - December is Fall"; break; default: << "Your month input is invalid"; break; }}} > Type: parsons Hardness: 20 //posttest // 15 cases - 4 groups // pH of 1-6 is acidic, 7 is neutral and 8-14 is basic # 2029 Switch.Parsons.Single.Empty > "It reads the pH value of a liquid (1-14) and prints whether it is acidic (1-6), neutral (7) or basic (8-14)." {(){ /* Declare */ ; /* Read */ << "Enter the pH value (1-14)"; >> ; /* Compute and print whether the liquid is acidic, neutral or basic */ /* --- Use ascending order of : 1 through 14 */ switch( ) { case 1: case 2: case 3: case 4: case 5: case 6: << "pH 1-6 is acidic"; break; case 7: << "pH 7 is neutral"; break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: << "pH 8-14 is basic"; break; default: << "Your pH input is invalid"; break; }}} > Type: parsons Hardness: 20 // 25 cases - 4 groups // AM, noon, PM and midnight for military hour after converting to civilian hour # 2030 Switch.Parsons.Single.Empty > "It reads the hour in military time (0-23), and prints the corresponding hour in civilian time, along with AM/PM/Noon/Midnight." {(){ /* Declare */ ; /* Read */ << "Enter the hour in military time (0-23)"; >> ; /* Compute and print civilian time and qualifier (AM/PM/Noon/Midnight) */ /* --- Use increasing order of : 0 - 23 */ switch( ) { case 0: << "12 midnight"; break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: << << " AM"; break; case 12: << << " Noon"; break; case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: << - 12 << " PM"; break; default: << "Your military hour input is invalid"; break; }}} > Type: parsons Hardness: 20 // elementary school (1-5), middle school (6-8), high school (9-12), college // -------------------------------------------------------------------------------------------- // Switch.Parsons.Multiple.Statements - 2050 // DemoParsons // 4-4 // Prints kilo/mega/giga/tera bit/byte/hertz/watts... # 2050 Switch.Parsons.Multiple.Statements > "It reads a unit of measurement as a character (h for hertz, i for bit, w for watt, and y for byte) and the scale (3 for kilo, 6 for mega, 9 for giga and 12 for tera). It prints the scale prefix followed by the unit in words (e.g., kilobits)." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the unit - h for hertz, i for bit, w for watt, y for byte"; >> ; /* Read */ << "Enter the prefix scale: 3, 6, 9 or 12"; >> ; /* Compute and print prefix: Kilo for 3, mega for 6, giga for 9, tera for 12 */ /* --- Use ascending order of the value of */ switch( ) { case 3: << "Kilo"; break; case 6: << "Mega"; break; case 9: << "Giga"; break; case 12: << "Tera"; break; } /* Compute and print the unit: hertz/bits/watts/bytes */ /* --- Use alphabetical order of the value of */ switch( ) { case 'h': << "hertz"; break; case 'i': << "bits"; break; case 'w': << "watts"; break; case 'y': << "bytes"; break; }}} > Type: parsons Hardness: 20 // pretest // 4-4 // Anniversaries: gold, platinum, tin.. of wedding/birthday/graduation/... # 2051 Switch.Parsons.Multiple.Statements > "It reads the anniversary year of an event (10/25/50/60) and the type of event as a character (birthday/graduation/job/wedding). It prints a happy anniversary message for the occasion." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the event - (b)irthday, (g)raduation, (j)ob or (w)edding"; >> ; /* Read */ << "Enter the anniversary year: 10/25/50/60"; >> ; /* Compute and print the type of anniversary */ /* --- Use ascending order of the value of */ switch( ) { case 10: << "Happy Tin (10 year) anniversary of "; break; case 25: << "Happy Silver (25 year) anniversary of "; break; case 50: << "Happy Golden (50 year) anniversary of "; break; case 60: << "Happy Diamond (60 year) anniversary of "; break; } /* Compute and print the type of event in words (e.g., birthday) */ /* --- Use alphabetical order of the value of */ switch( ) { case 'b': << "your birthday!"; break; case 'g': << "your graduation!"; break; case 'j': << "your job!"; break; case 'w': << "your wedding!"; break; }}} > Type: parsons Hardness: 20 // 4-4 // -3: milli, micro, nano, pico, femto, alto.. // Prints mill/micro/nano seconds/meters/... # 2052 Switch.Parsons.Multiple.Statements > "It reads a unit of measurement as a character (g for grams, k for kelvins, m for meters, and s for seconds) and the scale (-3 for milli, -6 for micro, -9 for nano and -12 for pico). It prints the scale prefix followed by the unit in words (e.g., milligrams)." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the unit - (g)rams, (k)elvins, (m)eters, or (s)econds"; >> ; /* Read */ << "Enter the prefix scale: -3, -6, -9 or -12"; >> ; /* Compute and print the prefix: Milli/micro/nano/pico */ /* --- Use decreasing order of the value of */ switch( ) { case -3: << "Milli"; break; case -6: << "Micro"; break; case -9: << "Nano"; break; case -12: << "Pico"; break; } /* Compute and print the unit: grams/kelvins/meters/seconds */ /* --- Use alphabetical order of the value of */ switch( ) { case 'g': << "grams"; break; case 'k': << "kelvins"; break; case 'm': << "meters"; break; case 's': << "seconds"; break; }}} > Type: parsons Hardness: 20 // post-test // 4-4 // 2 coupe 3 hatchback 4 sedan 5 stationwagon gas/deisel/electric/hybrid # 2053 Switch.Parsons.Multiple.Statements > "It reads the type of motor in a car (d for diesel, e for electric, g for gasoline, and h for hybrid) and the number of doors (2 for coupe, 3 for hatchback, 4 for sedan and 5 for wagon). It prints a description of the car in words (e.g., diesel coupe)." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter type of motor - (d)iesel, (e)lectric, (g)asoline, or (h)ybrid"; >> ; /* Read */ << "Enter the number of doors (2-5)"; >> ; /* Compute and print the type of motor in words */ /* --- Use increasing order: diesel/electric/gasoline/hybrid */ switch( ) { case 'd': << "Diesel "; break; case 'e': << "Electric "; break; case 'g': << "Gasoline "; break; case 'h': << "Hybrid "; break; } /* Compute and print the type of car based on doors */ /* --- Use increasing order of the value of */ switch( ) { case 2: << "coupe"; break; case 3: << "hatchback"; break; case 4: << "sedan"; break; case 5: << "wagon"; break; }}} > Type: parsons Hardness: 20 // 4-4 // 8/12/16/32 regular/diet/uncaffeinated/flavored coke/pepsi/sprite/ # 2054 Switch.Parsons.Multiple.Statements > "It reads the number of ounces (8 for small, 12 for medium, 16 for large and 32 for extra-large) and the type of soda (d for diet, f for flavored, r for regular and u for uncaffeinated). It prints the size and type of soda in words (e.g., small diet soda)." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the size in ounces (8/12/16/32)"; >> ; /* Read */ << "Enter the type - (d)iet, (f)lavored, (r)egular or (u)ncaffeinated"; >> ; /* Compute and print the size in words */ /* --- Use increasing order of value of */ switch( ) { case 8: << "Small "; break; case 12: << "Medium "; break; case 16: << "Large "; break; case 32: << "Extra-large "; break; } /* Compute and print the type of soda */ /* --- Use alphabetical order of the value of */ switch( ) { case 'd': << "diet soda"; break; case 'f': << "flavored soda"; break; case 'r': << "regular soda"; break; case 'u': << "uncaffeinated soda"; break; }}} > Type: parsons Hardness: 20 // 5-4 // Prints suit and face of card # 2055 Switch.Parsons.Single.Statements > "It reads the suit of a card as a character (c/d/s/h) and face of the card as a number. It prints the card in words (e.g., Ace of Spades)." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the suit - (c)lubs, (d)iamonds, (s)pades, or (h)earts"; >> ; /* Read */ << "Enter the face: 1-13"; >> ; /* Compute and print the name of the face (e.g., Ace) */ /* --- Use ascending order of the value of */ switch( ) { case 1: << "Ace of "; break; case 11: << "Jack of "; break; case 12: << "Queen of "; break; case 13: << "King of "; break; default: << << " of "; break; } /* Compute and print the suit of the card in words (e.g., Spades) */ /* --- Use alphabetical order of suit */ switch( ) { case 'c': << "Clubs"; break; case 'd': << "Diamonds"; break; case 'h': << "Hearts"; break; case 's': << "Spades"; break; }}} > Type: parsons Hardness: 20 // day of show and time (matinee, morning, ..) 7-4 // 5-9 // Prints in words 21 - 99, first the decade, then the number # 2056 Switch.Parsons.Single.Statements > "It reads the age of an employee as a number and prints the age in words (e.g., twenty three)." {(){ /* Declare */ ; /* Read */ << "Enter the age of the employee (20-67)"; >> ; /* Compute and print the first digit in words (e.g., twenty) */ /* --- Use ascending order */ switch( / 10 ) { case 2: << "twenty "; break; case 3: << "thirty "; break; case 4: << "forty "; break; case 5: << "fifty "; break; case 6: << "sixty "; break; } /* Compute and print the second digit in words (e.g., three) */ /* --- Use ascending order */ switch( % 10 ) { case 1: << "one"; break; case 2: << "two"; break; case 3: << "three"; break; case 4: << "four"; break; case 5: << "five"; break; case 6: << "six"; break; case 7: << "seven"; break; case 8: << "eight"; break; case 9: << "nine"; break; } }} > Type: parsons Hardness: 20 // distance of delivery and time in which to deliver // small/medium/large ice-cream/yogurt/sorbet // apple/orange/grape juice/jam/jelly/marmalade.. // Print small/medium/large/extra large ice-cream/yogurt/sorbet/juice // -------------------------------------------------------------------------------------------- // Switch.Parsons.Multiple.Empty - 2075 // given suit, print black or red suit, given face, print face or pip card // 1-10: print odd/even (1,3,5,7,9 and rest) followed by prime/non-prime (1,2,3,5,7 and rest) // -------------------------------------------------------------------------------------------- // Switch.Parsons.Nested.Statements - 2100 // Winning rock/paper/scissors // given heading (north,south,east,west) and the turn (left/right/around), print the new heading // -------------------------------------------------------------------------------------------- // Switch.Parsons.Nested.Empty - 2125 // -------------------------------------------------------------------------- // Templates here are for demonstration purposes // Included at the end so that regular practice does not pick up these templates // How to enter an output # 90 Demonstration > {(){=;<<;}} > Type: debug_output Hardness: 10 // Semantic error # 91 Demonstration > {(){;<<;}} > Type: debug_output Hardness: 10 // How to enter NO output # 92 Demonstration > {(){=;=;; = + ;}} > Type: debug_output Hardness: 10 // --------------------------------------------------------------------------