// 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: // ADD TEMPLATES FOR POSTSTATEMENT FOR BOTH IF AND IFELSE // ADD TEMPLATES FOR DECLARATION/OTHER AS CONDITION OF IF ELSE // POSTSTATEMENT MAKES MOST SENSE WHEN IF CLAUSE IS EXECUTED AND ELSE CLAUSE IS A SIMPLE STATEMENT // CURRENTLY, POSTSTATEMENT ADDED WHEN IF CONDITION FALSE AND ELSE CLAUSE IS A SIMPLE STATEMENT... // IMPLEMENT DANGLING ELSE // for problems with condition such as variable = value, could print value of variable before if // for contrast. // For condition being var declaration, could have debugging problem where var is accessed after the if. // FOR TEMPLATES 835 AND UP - THE EXPLANATION ABOUT EXITING AN IF DOES NOT READ SMOOTHLY - GOES BACK // AND FORTH BETWEEN LINES. // FOR NESTED IF/IF-ELSE TEMPLATES, MAY WANT TO NOT ASK USER TO PRINT INPUT VARS, BUT ONLY // THE CALCULATED VAR - TO REDUCE COGNITIVE LOAD. e.g., if user calcuates index based // on amount and count, ask to print only index, not also amount and count.. // // ------------------------------------------------------------------------------- // The actual learning objectives: // 100 // Selection.ifElse.Condition.Relational.true // Selection.ifElse.Condition.Relational.false // Selection.ifElse.Condition.Declaration.true // Selection.ifElse.Condition.Declaration.false // Selection.ifElse.Condition.Other.true // Selection.ifElse.Condition.Other.false // 250 // Selection.ifElse.ifClause.Simple // Selection.ifElse.ifClause.Compound // Selection.ifElse.elseClause.Simple // Selection.ifElse.elseClause.Compound // 350 // Selection.ifElse.PostStatement // 400 // Selection.ifElse.Nested.Cascading // Selection.ifElse.Nested.Classification // Selection.ifElse.Nested.Random // Selection.ifElse.Nested.DanglingElse // 500 // Selection.ifElse.Multiple // // 600 // Selection.if.Condition.Relational.true // Selection.if.Condition.Relational.false // Selection.if.Condition.Declaration.true // Selection.if.Condition.Declaration.false // Selection.if.Condition.Other.true // Selection.if.Condition.Other.false // 750 // Selection.if.ifClause.Simple // Selection.if.ifClause.Compound // 800 // Selection.if.PostStatement // 825 // Selection.if.Nested // 850 // Selection.if.Multiple // // --------------------------------------------------------------------------- // 100 // Selection.ifElse.Condition.Relational.true // All 6 relational operators, repeated twice // All 4 combinations of simple/compound if and else clauses # 100 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=;if( > )<<;else <<;}} > Type: output Hardness: 20 # 101 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=;if( != ){ = ; <<;} else <<;}} // {(){=;if( != ){<<;<<;} else <<;}} // Simplified for S08 > Type: output Hardness: 30 # 102 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;if( != )<<;else { = + 1; <<;}}} // {(){=;if( != )<<;else {<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 103 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;if( <= ){<<;<<;}else {<<; <<;}}} > Type: output Hardness: 40 # 104 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=;if( < )<<; else <<;}} > Type: output Hardness: 20 # 105 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;if( >= ){<<;<<;}else {<<;<<;}}} > Type: output Hardness: 40 # 106 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=;if( < ){ = - 1; <<;}else <<;}} // {(){=;if( < ){<<;<<;}else <<;}} // Simplified for S08 > Type: output Hardness: 30 # 107 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;=;if( >= )<<;else { = ; <<;}}} // {(){=;=;if( >= )<<;else {<<;<<;}}} // Simplified for S08 > Type: output Hardness: 30 # 108 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=; = + ;if( == * 2)<<; else <<;}} > Type: output Hardness: 30 # 109 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;=;if( <= )<<; else { = + ; <<;}}} // {(){=;=;if( <= )<<; else {<<;<<;}}} // Simplified for S08 > Type: output Hardness: 30 # 110 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;if( > ){<<;<<;} else {<<;<<;}}} > Type: output Hardness: 30 # 111 Selection.ifElse.Condition.Relational.true ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=; = * 2;if( - == ){<<; = + 1;} else <<;}} // {(){=; = * 2;if( - == ){<<;<<;} else <<;}} // Simplified for S08 > Type: output Hardness: 40 // Selection.ifElse.Condition.Relational.false *********************** 125 // All 6 relational operators, repeated twice // With Vs Without PostStatement // All 4 combinations of simple/compound if and else clauses # 125 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=;if( < )<<; else <<; }} > Type: output Hardness: 30 # 126 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=;=;if( == ){ = + 1; <<;}else <<;}} // {(){=;=;if( == ){<<;<<;}else <<;}} // Simplified for S08 > Type: output Hardness: 30 # 127 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;if( > )<<;else{=;<<;}}} // {(){=;if( > )<<;else{=;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 128 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;if( <= ){<<;<<;}else{<<;<<;}}} // {(){=;=;if( <= ){<<;<<;}else{<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 40 # 129 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=; = - ;if( != 0)<<;else <<;}} > Type: output Hardness: 30 # 130 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=;=;if( >= ){ = ; <<;}else <<;}} // {(){=;=;if( >= ){<<;<<;}else <<;}} // Simplified for S08 > Type: output Hardness: 40 # 131 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;if( < )<<;else{=;<<;}}} // {(){=;if( < )<<;else{=;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 132 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;if( == ){<<; = ; }else{<<; = ; }}} // {(){=;=;if( == ){<<;<<;}else{<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 40 # 133 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=;if( > )<<;else <<;}} > Type: output Hardness: 30 # 134 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=;=;if( <= ){ = + 1; <<;}else <<;}} // {(){=;=;if( <= ){<<;<<;}else <<;}} // Simplified for S08 > Type: output Hardness: 40 # 135 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=; = * 2;if( != + )<<;else{<<; = + 1;}}} // {(){=; = * 2;if( != + )<<;else{<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 136 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;if( >= ){<<;<<;}else{<<;<<;}}} // {(){=;=;if( >= ){<<;<<;}else{<<;<<;}=;<<;}} // Simplified for S08 > Type: output Hardness: 40 # 137 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=;if( < ){ = + 1; <<;}else <<;}} // {(){=;if( < ){<<;<<;}else <<;<<;}} // Simplified for S08 > Type: output Hardness: 30 # 138 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;=;if( == )<<;else{ = ; <<;}}} // {(){=;=;if( == )<<;else{<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 139 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;if( > ){ = + 1; <<;}else{=;<<;}}} // {(){=;if( > ){<<;<<;}else{=;<<;}}} // Simplified for S08 > Type: output Hardness: 30 # 140 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=;=;=;if( <= )<<;else <<;}} // {(){=;=;=;if( <= )<<;else <<; <<;}} // Simplified for S08 > Type: output Hardness: 40 # 141 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=; = + ;if( / 2 != ){<<;<<;}else{<<;<<;}}} > Type: output Hardness: 30 # 142 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=;=;if( >= )<< + 1;else << ;}} // {(){=;=;if( >= )<<;else <<;<< + 1;}} // Simplified for S08 > Type: output Hardness: 40 # 143 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;if( < ){<<;<<;}else{<<;<<;}}} > Type: output Hardness: 30 # 144 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Simple} > {(){=;if( == )<<; else <<; }} // {(){=;if( == )<<; else <<; <<;}} // Simplified for S08 > Type: output Hardness: 40 # 145 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=;if( > ){ = + 1; <<;}else <<;}} // {(){=;if( > ){<<;<<;}else <<;<<;}} // Simplified for S08 > Type: output Hardness: 30 # 146 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;=;if( <= )<<;else{<<; = ;}}} // {(){=;=;if( <= )<<;else{<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 147 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Compound,elseClause.Simple} > {(){=; = * 2;if( + != ){ = ; <<;}else<<;}} // {(){=; = * 2;if( + != ){<<;<<;}else<<;<<;}} // Simplified for S08 > Type: output Hardness: 40 # 148 Selection.ifElse.Condition.Relational.false ? Selection.ifElse.{ifClause.Simple,elseClause.Compound} > {(){=;=;if( >= )<<;else{ <<; = + 1;}}} // {(){=;=;if( >= )<<;else{<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 // Selection.ifElse.Condition.Declaration.true // Selection.ifElse.Condition.Declaration.false // Selection.ifElse.Condition.Other.true // Selection.ifElse.Condition.Other.false // 250 // Selection.ifElse.ifClause.Simple // Selection.ifElse.ifClause.Compound // Selection.ifElse.elseClause.Simple // Selection.ifElse.elseClause.Compound // 350 // Selection.ifElse.PostStatement // Selection.ifElse.Nested.Cascading **************************************************** 400 // Cascading if Vs else // Alternate simple and compound statements # 400 // ph value Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;;if( < 7) = -1; else {if( == 7 ) = 0; else = 1;} <<;}} // {(){=;;if( < 7) = -1; else {if( == 7 ) = 0; else = 1;} <<; <<;}} // Simplified for S08 > Type: output Hardness: 70 # 401 // solid, liquid, gas temperatures of water Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;;if( <= 0) = 0; else {if( < 100 ) = 1; else = 2;} <<;}} // {(){=;;if( <= 0) = 0; else {if( < 100 ) = 1; else = 2;} <<; <<;}} // Simplified for S08 > Type: output Hardness: 70 # 402 // Month -> Season Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;;if( >= 10){ = 4;} else {if( >= 7 ){ = 3;} else {if( >= 4){ = 2;} else { = 1;}}} <<;}} // {(){=;;if( >= 10){ = 4;} else {if( >= 7 ){ = 3;} else {if( >= 4){ = 2;} else { = 1;}}} <<; <<;}} // Simplified for S08 > Type: output Hardness: 70 # 403 // Degrees and quadrants Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;;if( <= 90){ = 1;} else {if( <= 180 ){ = 2;} else {if( <= 270){ = 3;} else { = 4;}}} <<;}} // {(){=;;if( <= 90){ = 1;} else {if( <= 180 ){ = 2;} else {if( <= 270){ = 3;} else { = 4;}}} <<; <<;}} // Simplified for S08 > Type: output Hardness: 70 # 404 // Credits -> year Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;;if( <= 28) = 1; else{ if( <= 58 ) = 2; else{ if( <= 85 ) = 3; else = 4;}} <<; }} // {(){=;;if( <= 28) = 1; else{ if( <= 58 ) = 2; else{ if( <= 85 ) = 3; else = 4;}} <<; <<; }} // Simplified for S08 > Type: output Hardness: 70 # 405 // Grade -> GPA Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;;if( >= 90) = 4; else {if( >= 80 ) = 3; else{ if( >= 70 ) = 2; else {if( >= 55 ) = 1; else = 0;}}} <<; }} // {(){=;;if( >= 90) = 4; else {if( >= 80 ) = 3; else{ if( >= 70 ) = 2; else {if( >= 55 ) = 1; else = 0;}}} <<; <<; }} // Simplified for S08 > Type: output Hardness: 70 # 406 // leap year Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;;if( % 4 == 0){if( % 100 == 0 ){if( % 400 == 0){ = 1;}else { = 0;}} else { = 1;}} else{ = 0;} <<;}} // {(){=;;if( % 4 == 0){if( % 100 == 0 ){if( % 400 == 0){ = 1;}else { = 0;}} else { = 1;}} else{ = 0;}<<; <<;}} // Simplified for S08 > Type: output Hardness: 70 # 407 // slope based on deltax and deltay Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;=;;if( == 0) = 0; else {if( == ) = 1; else{ if( < ) = -2; else = 2;}} <<; }} // {(){=;=;;if( == 0) = 0; else {if( == ) = 1; else{ if( < ) = -2; else = 2;}}<<;<<;<<; }} // Simplified for S08 > Type: output Hardness: 70 # 408 // Tsunami scale Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;; if( <= 72) = 0; else {if( <= 112 ) = 1; else {if( <= 157 ) = 2; else {if( <= 206 ) = 3; else {if( <= 260 ) = 4; else {if( <= 318 ) = 5; else = 6;}}}}} <<;}} // {(){=;; if( <= 72) = 0; else {if( <= 112 ) = 1; else {if( <= 157 ) = 2; else {if( <= 206 ) = 3; else {if( <= 260 ) = 4; else {if( <= 318 ) = 5; else = 6;}}}}} <<; <<;}} // Simplified for S08 > Type: output Hardness: 70 # 409 // frequency vs decible scale Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;; if( <= 200) = 20; else {if( <= 2000 ) = 40; else {if( <= 20000 ) = 60; else {if( <= 200000 ) = 80; else = 100;}}} <<;}} // {(){=;; if( <= 200) = 20; else {if( <= 2000 ) = 40; else {if( <= 20000 ) = 60; else {if( <= 200000 ) = 80; else = 100;}}} <<;<<;}} // Simplified for S08 > Type: output Hardness: 70 # 410 // Frequencies and colors (in reverse order of VBGYOR) Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;; if( < 482) = 1; else {if( < 503 ) = 2; else {if( < 520 ) = 3; else {if( < 610 ) = 4; else {if( < 659 ) = 5; else = 6;}}}} <<;}} // {(){=;; if( < 482) = 1; else {if( < 503 ) = 2; else {if( < 520 ) = 3; else {if( < 610 ) = 4; else {if( < 659 ) = 5; else = 6;}}}}<<;<<;}} // Simplified for S08 > Type: output Hardness: 70 # 411 // Plant hardiness zone based on low temperature Selection.ifElse.Nested.Cascading ? Selection.ifElse.{ifClause.Simple,elseClause.{Simple,Compound}} > {(){=;; if( < -50) = 1; else {if( < -40 ) = 2; else {if( < -30 ) = 3; else {if( < -20 ) = 4; else {if( < -10 ) = 5; else {if( < 0 ) = 6; else {if( < 10) = 7; else {if( < 20) = 8; else{if( < 30) = 9; else {if( < 40 ) = 10; else = 11;}}}}}}}}} <<;}} // {(){=;; if( < -50) = 1; else {if( < -40 ) = 2; else {if( < -30 ) = 3; else {if( < -20 ) = 4; else {if( < -10 ) = 5; else {if( < 0 ) = 6; else {if( < 10) = 7; else {if( < 20) = 8; else{if( < 30) = 9; else {if( < 40 ) = 10; else = 11;}}}}}}}}} <<; <<;}} // Simplified for S08 > Type: output Hardness: 70 // temperature and type of candy: 235-240 soft 245-250 firm 250-265 hard ball 270-290 soft crack 300-310 hard crack 320-356 caramelized // Selection.ifElse.Nested.Classification *************************************************** 425 // 4-way // 8-way # 425 // movie admission fee: age, show Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=;;if( <= 9){if( <= 2 ) = 4; else = 6;}else {if( <= 2 ) = 8; else = 10; } <<;}} // {(){=;=;;if( <= 9){if( <= 2 ) = 4; else = 6;}else {if( <= 2 ) = 8; else = 10; } <<; <<; <<;}} // Simplified for S08 > Type: output Hardness: 80 # 426 // quartile of a number 1-100 Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;;if( >= 50){if( < 75 ) = 3; else = 4;}else {if( < 25) = 1; else = 2; } <<;}} // {(){=;;if( >= 50){if( < 75 ) = 3; else = 4;}else {if( < 25) = 1; else = 2; } <<; <<;}} // Simplified for S08 > Type: output Hardness: 80 # 427 // two numbers, operations based on their positive/negative nature Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;;if( >= 0){if( >= 0){ = + ;}else{ = ;}}else{if( >= 0){ = ;}else{ = 0;}} <<;}} // {(){=;=;;if( >= 0){if( >= 0){ = + ;}else{ = ;}}else{if( >= 0){ = ;}else{ = 0;}} <<;<<;<<;}} // Simplified for S08 > Type: output Hardness: 80 # 428 // cards in a hand Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;;if( <= 10){if( <= 2){ = 15;}else{ = 25;}}else{if( == 1){ = 30;}else{ = 50;}} <<;}} // {(){=;=;;if( <= 10){if( <= 2){ = 15;}else{ = 25;}}else{if( == 1){ = 30;}else{ = 50;}} <<; <<; <<;}} // Simplified for S08 > Type: output Hardness: 80 # 429 // positive/negative, odd even Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;;if( >= 0){if( % 2 == 0 ) = 4; else = 3;}else {if( % 2 == 0 ) = 2; else = 1; } <<;}} // {(){=;;if( >= 0){if( % 2 == 0 ) = 4; else = 3;}else {if( % 2 == 0 ) = 2; else = 1; } <<; <<;}} // Simplified for S08 > Type: output Hardness: 80 # 430 // Rent based on no. of bedrooms and bathrooms Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=;;if( == 2){if( == 1 ) = 1200; else = 1500;}else {if( == 3 ){if( == 1 ) = 1500; else = 1800;} else{if( <= 2 ) = 2100; else = 2500;}} <<; }} // {(){=;=;;if( == 2){if( == 1 ) = 1200; else = 1500;}else {if( == 3 ){if( == 1 ) = 1500; else = 1800;} else{if( <= 2 ) = 2100; else = 2500;}}<<;<<;<<; }} // Simplified for S08 > Type: output Hardness: 80 # 431 // ice-cream: scoops, toppings Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=;;if( == 1){if( == 0 ) = 100; else = 150;}else {if( == 2 ){if( == 0 ) = 180; else = 220;} else{if( == 0 ) = 250; else = 300;}} <<; }} // {(){=;=;;if( == 1){if( == 0 ) = 100; else = 150;}else {if( == 2 ){if( == 0 ) = 180; else = 220;} else{if( == 0 ) = 250; else = 300;}}<<;<<;<<; }} // Simplified for S08 > Type: output Hardness: 80 # 432 // speeding tickets: speed, age Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=;;if( <= 10){if( <= 21 ) = 80; else{ if( <= 25 ) = 60; else = 50;}} else {if( <= 30 ){if( <= 21 ) = 120; else{ if( <= 25 ) = 100; else = 80;}} else {if( <= 21 ) = 200; else{ if( <= 25 ) = 150; else = 120;}}} <<; }} // {(){=;=;;if( <= 10){if( <= 21 ) = 80; else{ if( <= 25 ) = 60; else = 50;}} else {if( <= 30 ){if( <= 21 ) = 120; else{ if( <= 25 ) = 100; else = 80;}} else {if( <= 21 ) = 200; else{ if( <= 25 ) = 150; else = 120;}}}<<;<<;<<; }} // Simplified for S08 > Type: output Hardness: 80 # 433 // Income tax rate Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=;;if( == 0){if( <= 30 ) = 15; else{ if( <= 80 ) = 30; else = 40;}} else {if( <= 40 ) = 10; else {if( <= 100 ) = 25; else = 35;}} <<;}} // {(){=;=;;if( == 0){if( <= 30 ) = 15; else{ if( <= 80 ) = 30; else = 40;}} else {if( <= 40 ) = 10; else {if( <= 100 ) = 25; else = 35;}} <<; <<; <<;}} // Simplified for S08 > Type: output Hardness: 80 # 434 // sorting 3 numbers Selection.ifElse.Nested.Classification ? Selection.ifElse.{ifClause.Compound,elseClause.Compound} > {(){=;=;=; if( > ){if( > ) {<<; <<; <<;} else {if( > ) {<<; <<; <<;} else {<<;<<;<<;} }} else {if( > ) { if( > ) {<<; <<; <<;} else {<<; <<; <<;} } else {<<; <<; <<;}}}} > Type: output Hardness: 80 // Heading N/E/W/S and turn L/R/Around - new heading // Selection.ifElse.Nested.Random *********************************** 450 // // Selection.ifElse.Nested.DanglingElse ***************************** 475 // Selection.ifElse.Multiple ***************************************** 500 // 2 Vs 3 statements // 2 levels - TT, TF, FT, FF // 3 levels - TTT, TTF, TFT, TFF, FTT, FTF, FFT FFF // (Same variable Vs different variables, all 6 relational operators) - NO postStatement, Compound Vs Simple mixed # 500 // 2 levels - TT, positive and negative numbers Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.true,ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=;if( > ) <<; else {<<;}; if( - >= 0){ = - ;} else = - ; << ;}} > Type: output Hardness: 60 # 501 // 2 levels - TF, Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=; = ;if( > ){<<; <<;} else {<<;<<;} = - ; = + ; if( > ) <<; else <<; }} > Type: output Hardness: 60 # 502 // 2 levels - FT, Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=; if( >= ) {<<;} else <<; = * ; if( <= ) <<; else {<<;}}} > Type: output Hardness: 60 # 503 // 2 levels - FF, -ve numbers Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.false,ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=; = * -1; if( == )<<;else <<; = * ; = * ; if( != ){ <<;} else {<<;} }} // {(){=; = * -1; if( == )<<;else <<; = * ; = * ; if( != ){ <<;} else {<<; <<;} }} // Simplified for S08 > Type: output Hardness: 60 // TTT - a < b, b < c, c < d // a,b,c < x // TTF - a < x, y, z // with vs without accumulator variable // print smaller // a == b == c or a != b != c # 505 // 3 levels - TTT Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.true,ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=;=;if( < )<< ; else << ; if( <= ) << ; else << ; if( < ) {<<;} else {<<;}}} > Type: output Hardness: 60 # 506 // 3 levels - TTF Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;if( > )<< ; else {<< - ;} if( >= ) << ; else {<< - ;} if( >= ){ << - ;} else <<; }} > Type: output Hardness: 60 # 507 // 3 levels - TFT - <, >, != Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=; = * -1; if( < ) <<; else <<; if( + != 0){ << + ;} else { <<;} if( * == * ) {<< * ;} else { << + ;}}} // {(){=; = * -1; if( < ) <<; else <<; if( + != 0){ << + ;} else { <<; <<;} if( * == * ) {<< * ;} else { << * ; << * ;}}} // Simplified for S08 > Type: output Hardness: 60 # 508 // 3 levels - TFF - Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.{Simple,Compound},elseClause.{Simple,Compound}} > {(){=;=; if( != ){<<;}else <<; = ; if( == ) << ; else <<; if( == ) {<<;} else {<<;}}} > Type: output Hardness: 60 # 509 // 3 levels - FFF Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.false,ifClause.{Simple,Compound},elseClause.Compound,PostStatement} > {(){=; = 0; if( >= ) = - 1; else { = + 1;} if( >= ) { = - 1; } else { = + 1;} if( >= ) = - 1; else { = + 1;} <<;}} // {(){=; = 0; if( >= ) << ; else {<<; = + 1;} if( >= ) { <<; } else {<<; = + 1;} if( >= )<<; else {<<; = + 1;} <<;}} // Simplified for S08 > Type: output Hardness: 70 # 510 // 3 levels - FTT - Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.Compound,elseClause.{Simple,Compound},PostStatement} > {(){=;=; = 0;if( >= ){ = + 2;} else = - 1; =; if( >= ){ = + 2;} else = - 1; if( >= ) { = + 2;} else { = - 1;} <<;}} // {(){=;=; = 0;if( >= ){<< ; = + 1;} else << ; =; if( >= ){ << ; = + 1;} else << ; if( >= ) {<<; = + 1;} else {<<;} <<;}} // Simplified for S08 > Type: output Hardness: 70 # 511 // 3 levels - NOT FFT, but Sieve of Eratosthenes Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.Simple,elseClause.Simple} > {(){=;=; if( > ) = - ; else = - ; <<; <<; if( > ) = - ; else = - ; <<; <<; if( > ) = - ; else = - ; <<; <<; }} > Type: output Hardness: 80 # 512 // 3 levels - NOT FTF, but divide/subtract based on even/odd Selection.ifElse.Multiple ? Selection.ifElse.{Condition.Relational.{true,false},ifClause.Simple,elseClause.Simple} > {(){=; if( % 2 == 0){ = / 2;} else = - 1; <<; if( % 2 == 0){ = / 2;} else = - 1; <<; if( % 2 == 0){ = / 2;} else = - 1; <<;}} > Type: output Hardness: 80 // 600 // Selection.if.Condition.Relational.true **************************** 600 // All six relational operators // Simple Vs Compound if-clause // PostStatement not very effective when condition is true - equivalent to sequential execution # 600 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Simple > {(){=;if( > )<<;}} > Type: output Hardness: 10 # 601 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Simple > {(){=;if( != )<<;}} > Type: output Hardness: 10 # 602 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Simple > {(){=;if( < )<<;}} > Type: output Hardness: 10 # 603 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Simple > {(){=;=;if( >= )<<;}} > Type: output Hardness: 20 # 604 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Simple > {(){=; = + ;if( == * 2)<<;}} > Type: output Hardness: 20 # 605 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Simple > {(){=;=;if( <= )<<;}} > Type: output Hardness: 20 # 610 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Compound > {(){=;if( > ){<<; = ;}}} // {(){=;if( > ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 611 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Compound > {(){=;if( != ){<<; = + 1;}}} // {(){=;if( != ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 612 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Compound > {(){=;if( < ){<<; = - 1;}}} // {(){=;if( < ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 613 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Compound > {(){=;=;if( >= ){<< - ; = ;}}} // {(){=;=;if( >= ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 30 # 614 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Compound > {(){=; = * 2;if( - == ){<<; = + 1;}}} // {(){=; = * 2;if( - == ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 30 # 615 Selection.if.Condition.Relational.true ? Selection.if.ifClause.Compound > {(){=;=;if( <= ){<< - ; = ;}}} // {(){=;=;if( <= ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 30 // Selection.if.Condition.Relational.false ************************************** 625 // All six relational operators // Simple Vs Compound if-clause // With Vs without PostStatement # 625 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;if( < )<<;}} > Type: output Hardness: 10 # 626 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;if( == )<<;}} // {(){=;if( == )<<;<<;}} // Simplified for S08 > Type: output Hardness: 20 # 627 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;if( > )<<;}} > Type: output Hardness: 10 # 628 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;=;if( <= )<<;}} // {(){=;=;if( <= )<<;<<;}} // Simplified for S08 > Type: output Hardness: 20 # 629 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=; = + ;if( != * 2)<<;}} > Type: output Hardness: 20 # 630 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;=;if( >= )<<;}} // {(){=;=;if( >= )<<;<<;}} // Simplified for S08 > Type: output Hardness: 20 # 631 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;if( < ){ = - 1; <<;}}} // {(){=;if( < ){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 632 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;if( == ){<<; <<;}}} // {(){=;if( == ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 633 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;if( > ){<<; = ;}}} // {(){=;if( > ){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 634 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;=;if( <= ){ = ; <<;}}} // {(){=;=;if( <= ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 635 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=; = * 2;if( - != ){ = ; <<;}}} // {(){=; = * 2;if( - != ){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 636 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;=;if( >= ){<<; = ;}}} // {(){=;=;if( >= ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 637 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;if( < )<<;}} // {(){=;if( < )<<;<<;}} // Simplified for S08 > Type: output Hardness: 20 # 638 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;if( == )<<;}} > Type: output Hardness: 10 # 639 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;if( > )<<;}} // {(){=;if( > )<<;<<;}} // Simplified for S08 > Type: output Hardness: 20 # 640 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;=;if( <= )<<;}} > Type: output Hardness: 10 # 641 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=; = + ;if( != * 2)<<;}} // {(){=; = + ;if( != * 2)<<;<<;}} // Simplified for S08 > Type: output Hardness: 20 # 642 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Simple > {(){=;=;if( >= )<<;}} > Type: output Hardness: 10 # 643 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;if( < ){<<; = ;}}} // {(){=;if( < ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 644 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;if( == ){<<; = + ;}}} // {(){=;if( == ){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 645 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;if( > ){<<; = - ;}}} // {(){=;if( > ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 646 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;=;if( <= ){ = ; <<;}}} // {(){=;=;if( <= ){<<;<<;}<<;<<;}} // Simplified for S08 > Type: output Hardness: 30 # 647 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=; = * 2;if( - != ){<<; = ;}}} // {(){=; = * 2;if( - != ){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 20 # 648 Selection.if.Condition.Relational.false ? Selection.if.ifClause.Compound > {(){=;=;if( >= ){ = + ; <<;}}} // {(){=;=;if( >= ){<<;<<;}<<;<<;}} // Simplified for S08 > Type: output Hardness: 30 // Selection.if.Condition.Declaration.true ******************************* 650 // Boolean Vs Integer condition variable // Simple Vs Compound if-clause // With Vs without PostStatement # 650 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Simple > {(){if( = true)<< ;}} > Type: output Hardness: 40 # 651 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Simple > {(){ = ;if( = true)<<;}} // {(){ = ;if( = true)<<;<<;}} // Simplified for S08 > Type: output Hardness: 40 # 652 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Compound > {(){if( = ){<<; = * 2;}}} // {(){if( = ){<<;<< + 1;}}} // Simplified for S08 > Type: output Hardness: 40 # 653 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Compound > {(){ = ;if( = ){ = ; <<;}}} // {(){ = ;if( = ){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 40 # 654 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Simple > {(){if(=)<<;}} > Type: output Hardness: 40 # 655 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Simple > {(){=;if(=)<<;}} // {(){=;if(=)<<;<<;}} // Simplified for S08 > Type: output Hardness: 40 # 656 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Compound > {(){if( = true){<<;}}} > Type: output Hardness: 40 # 657 Selection.if.Condition.Declaration.true ? Selection.if.ifClause.Compound > {(){=;if( = true){<<; = * 2;}}} // {(){=;if( = true){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 40 // Selection.if.Condition.Declaration.false ****************************** 675 // Boolean Vs Integer condition variable // Simple Vs Compound if-clause // With Vs without PostStatement # 675 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Simple > {(){if( = false)<<;}} > Type: output Hardness: 40 # 676 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Simple > {(){=;if( = false)<<;}} // {(){=;if( = false)<<;<<;}} // Simplified for S08 > Type: output Hardness: 40 # 677 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Compound > {(){if( = 0){<<; = + 1;}}} // {(){if( = 0){<<;<< + 1;}}} // Simplified for S08 > Type: output Hardness: 40 # 678 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Compound > {(){=;if( = 0){ = ; <<;}}} // {(){=;if( = 0){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 40 # 679 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Simple > {(){if( = 0)<<;}} > Type: output Hardness: 40 # 680 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Simple > {(){=;if( = 0)<<;}} // {(){=;if( = 0)<<;<<;}} // Simplified for S08 > Type: output Hardness: 40 # 681 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Compound > {(){if( = false){<<;}}} > Type: output Hardness: 40 # 682 Selection.if.Condition.Declaration.false ? Selection.if.ifClause.Compound > {(){=;if( = false){<<; = ;}}} // {(){=;if( = false){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 40 // Selection.if.Condition.Other.true ************************************* 700 // Condition is: // Literal Constant - integer, boolean // Symbolic Constant? // Assignment to a pre-declared variable // Arithmetic expression - with or without variables, mostly +,- // -ve numbers as true # 700 Selection.if.Condition.Other.true ? Selection.if.ifClause.Simple > {(){=;if()<<;}} > Type: output Hardness: 40 # 701 Selection.if.Condition.Other.true ? Selection.if.ifClause.Simple > {(){=;if( = )<<;}} > Type: output Languages: C++ C Hardness: 40 # 702 Selection.if.Condition.Other.true ? Selection.if.ifClause.Compound > {(){=;=;if( + ){ = ; <<;}}} // {(){=;=;if( + ){<<; <<;}}} // Simplified for S08 > Type: output Hardness: 40 # 703 Selection.if.Condition.Other.true ? Selection.if.ifClause.Compound > {(){=;if( * -1){ = * -1; <<;}}} // {(){=;if( * -1){<<; << * -1;}}} // Simplified for S08 > Type: output Hardness: 40 # 704 Selection.if.Condition.Other.true ? Selection.if.ifClause.Simple > {(){=;if(true)<<;}} > Type: output Languages: C++ C Hardness: 40 # 705 Selection.if.Condition.Other.true ? Selection.if.ifClause.Compound > {(){=;=;if( = ){<<; = ;}}} // {(){=;=;if( = ){<<; <<;}}} // Simplified for S08 > Type: output Languages: C++ C Hardness: 40 # 706 Selection.if.Condition.Other.true ? Selection.if.ifClause.Compound > {(){=;=;if( - ){ = + 1; <<;}}} // {(){=;=;if( - ){<<; <<;}}} // Simplified for S08 > Type: output Hardness: 40 # 707 Selection.if.Condition.Other.true ? Selection.if.ifClause.Simple > {(){=;if()<<;}} > Type: output Hardness: 40 # 708 Selection.if.Condition.Other.true ? Selection.if.ifClause.Compound > {(){=;=;if( - ){ = - 1; <<;}}} // {(){=;=;if( - ){<<; <<;}}} // Simplified for S08 > Type: output Hardness: 40 // Selection.if.Condition.Other.false ************************************ 725 // Literal Constant - integer, boolean // Symbolic Constant? // Assignment to a pre-declared variable // Arithmetic expression - with or without variables, mostly +,- # 725 Selection.if.Condition.Other.false ? Selection.if.ifClause.Simple > {(){=0;if()<<;}} > Type: output Hardness: 40 # 726 Selection.if.Condition.Other.false ? Selection.if.ifClause.Simple > {(){=;if( = 0)<<;}} > Type: output Languages: C++ C Hardness: 40 # 727 Selection.if.Condition.Other.false ? Selection.if.ifClause.Compound > {(){=;=;if( - ){ = + 1; <<;}}} // {(){=;=;if( - ){<<; <<;}}} // Simplified for S08 > Type: output Hardness: 40 # 728 Selection.if.Condition.Other.false ? Selection.if.ifClause.Simple > {(){=;if(false)<<;}} > Type: output Languages: C++ C Hardness: 40 # 729 Selection.if.Condition.Other.false ? Selection.if.ifClause.Compound > {(){=;=0;if( = ){ = + 1; <<;}}} // {(){=;=0;if( = ){<<; <<;}}} // Simplified for S08 > Type: output Languages: C++ C Hardness: 40 # 730 Selection.if.Condition.Other.false ? Selection.if.ifClause.Simple > {(){=;if( * 0)<<; }} > Type: output Hardness: 40 # 731 Selection.if.Condition.Other.false ? Selection.if.ifClause.Compound > {(){=;=;if( / ){ = - 1; <<;}}} // {(){=;=;if( / ){<<; <<;}}} // Simplified for S08 > Type: output Hardness: 40 # 732 Selection.if.Condition.Other.false ? Selection.if.ifClause.Compound > {(){=;=;if( + ){<< ; <<;}}} > Type: output Hardness: 40 // 750 // Selection.if.ifClause.Simple // Selection.if.ifClause.Compound // 800 // Selection.if.PostStatement // Selection.if.Nested *************************************** 825 // 2 Vs 3 levels // 2 levels - True-True Vs True-False Vs False-True // 3 levels - TTT, TTF, TFT, FTT // Compound Vs Simple // (Same variable Vs different variables, all 6 relational operators) - NO postStatement // Compound Statement - all are set as compound statements because of problem with indenting code (as described before) # 825 // 2 levels - TT, two var, - number and its square Selection.if.Nested ? Selection.if.{Condition.Relational.true,ifClause.Compound} > {(){=;if( <= ){ = * ; if( >= ){ = + 1; <<;}}}} // {(){=;if( <= ){ = * ; if( >= ){ <<; <<;}}}} // Simplified for S08 > Type: output Hardness: 50 # 826 // 2 levels - TF - one var, Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;if( >= ){ if( - == 0){ <<;}}}} > Type: output Hardness: 50 # 827 // 2 levels - FT, two vars, sum/difference Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;=;if( - > 0){ if( + > 0){ <<;}}}} > Type: output Hardness: 50 # 830 // 3 levels - TTT, three vars, var in range Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;if( <= ){ = + ; if( <= ){ = + ; if( <= ) { = ; <<; }}}}} // {(){=;if( <= ){ = + ; if( <= ){ = + ; if( <= ) { <<; <<; <<;}}}}} // Simplified for S08 > Type: output Hardness: 50 # 831 // 3 levels - TTF, three vars, monotonicity Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;=; =; = 0; if( >= ){ = + 1; if( >= ){ = + 1; if( >= ){ = + 1;}}} <<;}} // {(){=;=; if( >= ){<<; =; if( >= ){<<; if( >= ){ <<;}}}}} // Simplified for S08 > Type: output Hardness: 50 # 832 // 3 levels - TFT, sum, difference Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;=;if( != ){ <<; if( - >= 0){<< - ; if( + >= ){ << + ;}}}}} // {(){=;=;if( != ){ <<; <<; if( - >= 0){<< - ; if( + >= ){ << + ;}}}}} // Simplified for S08 > Type: output Hardness: 50 # 833 // 3 levels - FTT Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;=; = 111;if( == ){ = - 100; if( * >= 0){ = - 10; if( * >= ){ = - 1; }}} <<; }} // {(){=;=;if( == ){ <<; <<; if( * >= 0){ << * ; if( * >= ){ << * ;}}}}} // Simplified for S08 > Type: output Hardness: 50 // Simple Statement - harder than compound statement, hence, later in the template list. # 835 // 2 levels - TT, one var, 2 comparators Selection.if.Nested ? Selection.if.{Condition.Relational.true,ifClause.Simple} > {(){=;if( < ) if( <= ) <<;}} > Type: output Hardness: 50 # 836 // 2 levels - TF - two vars, one comparator Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Simple} > {(){=;=;if( > ) if( >= ) = ; <<;}} // {(){=;=;if( > ) if( >= ) <<;}} // Simplified for S08 > Type: output Hardness: 50 # 837 // 2 levels - FT, two vars, two comparators Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Simple} > {(){=;=;if( > ) if( <= ) = ; <<;}} // {(){=;=;if( > ) if( <= ) <<;}} // Simplified for S08 > Type: output Hardness: 50 # 840 // 3 levels - TTT, one var, var in range Selection.if.Nested ? Selection.if.{Condition.Relational.true,ifClause.Simple} > {(){=;if( >= ) if( <= ) if( != ) = ; <<;}} // {(){=;if( >= ) if( <= ) if( != ) <<;}} // Simplified for S08 > Type: output Hardness: 50 # 841 // 3 levels - TTF, three vars, monotonicity Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Simple} > {(){=;=;=; if( < ) if( <= ) if( <= ) = ; <<;}} // {(){=;=;=; if( < ) if( <= ) if( <= ) <<;}} // Simplified for S08 > Type: output Hardness: 50 # 842 // 3 levels - TFT Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Simple} > {(){=;=;if( > ) if( >= ) if( + >= ) = ; <<;}} // {(){=;=;if( > ) if( >= ) if( + >= ) <<;}} // Simplified for S08 > Type: output Hardness: 50 # 843 // 3 levels - FTT Selection.if.Nested ? Selection.if.{Condition.Relational.{true,false},ifClause.Simple} > {(){=;=;if( + == 0) if( >= 0) if( <= 0 ) = ; <<;}} // {(){=;=;if( + == 0) if( >= 0) if( <= 0 ) <<;}} // Simplified for S08 > Type: output Hardness: 50 // 850 // Selection.if.Multiple // 2 Vs 3 statements // 2 levels - TT, TF, FT, FF // 3 levels - TTT, TTF, TFT, TFF, FTT, FTF, FFT FFF // (Same variable Vs different variables, all 6 relational operators) - NO postStatement, Compound Vs Simple mixed # 850 // 2 levels - TT, positive and negative numbers Selection.if.Multiple ? Selection.if.{Condition.Relational.true,ifClause.{Simple,Compound}} > {(){=;=;if( > ){<<; = + 1;} if( < 0) <<;}} // {(){=;=;if( > ){<<; <<;} if( + >= 0) << + ;}} // Simplified for S08 > Type: output Hardness: 50 # 851 // 2 levels - TT, <=, >= Selection.if.Multiple ? Selection.if.{Condition.Relational.true,ifClause.{Simple,Compound}} > {(){=;=;if( >= ) <<; if( <= ){ <<;}}} > Type: output Hardness: 50 # 852 // 2 levels - TF, !=, == Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.{Simple,Compound}} > {(){=;=;if( != )<<; if( - == 0) {<< ; = + 1;}}} // {(){=;=;if( != )<<; if( - == 0) {<< ; << ;}}} // Simplified for S08 > Type: output Hardness: 50 # 853 // 2 levels - FT, >, < Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;=;if( > ){<<; <<;} if( < ) {<< ; << ;}}} > Type: output Hardness: 50 # 854 // 2 levels - FF, -ve numbers Selection.if.Multiple ? Selection.if.{Condition.Relational.false,ifClause.Simple} > {(){=;if( + > 0)<<; if( - != 0) << ;}} > Type: output Hardness: 50 # 855 // 3 levels - TTT, +, - and / of two integers being > 0 Selection.if.Multiple ? Selection.if.{Condition.Relational.true,ifClause.{Simple,Compound}} > {(){=;=;if( + > 0)<< ; if( - >= 0) << ; if( * > 0 ) {<< + ; = ;}}} // {(){=;=;if( + > 0)<< ; if( - >= 0) << ; if( / > 0 ) {<<; << ;}}} // Simplified for S08 > Type: output Hardness: 50 # 856 // 3 levels - TTF: doubling a number and subtracting itself Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;= * 2;= - ;if( != )<< ; if( != ) << ; if( != ) {<< - ; = ;}}} // {(){=;= * 2;= - ;if( != )<< ; if( != ) << ; if( != ) {<<; << ;}}} // Simplified for S08 > Type: output Hardness: 50 # 857 // 3 levels - TFT - <, >, != Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.Compound} > {(){=;=;if( < ){<<;} if( > ) << ; if( != ) {<< - ; = ;}}} // {(){=;=;if( < ){<<;} if( > ) << ; if( != ) {<<; <<;}}} // Simplified for S08 > Type: output Hardness: 50 # 858 // 3 levels - TFF - Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.{Simple,Compound}} > {(){=;if( > 0){<<; = - 1;} = - ; if( > 0) << ; if( <= ) {<< - ; = ;}}} // {(){=;if( > 0){<<;} = - ; if( > 0) << ; if( <= ) {<<; <<;}}} // Simplified for S08 > Type: output Hardness: 50 # 859 // 3 levels - FFF Selection.if.Multiple ? Selection.if.{Condition.Relational.false,ifClause.Simple} > {(){=;if( + 1 < * 1) <<; if( + 2 > * 2 ) << + 2; if( + 3 > * 3)<< + 3;}} > Type: output Hardness: 50 # 860 // 3 levels - FTT - monotonicity Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.{Simple,Compound}} > {(){=;=;if( < ){<<;<<;} = + ;if( < ) << ; if( <= ) {<<; = ;}}} // {(){=;=;if( < ){<<;} = + ;if( < ) << ; if( <= ) {<<; <<;}}} // Simplified for S08 > Type: output Hardness: 50 # 861 // 3 levels - FFT - binary search Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.{Simple,Compound}} > {(){=;if( > 20){<< - 20; = - 20;} if( > 10) << - 10; if( >= 5) {<<; = + 20;}}} // {(){=;if( > 20){<< - 20;} if( > 10) << - 10; if( >= 5) {<<;}}} // Simplified for S08 > Type: output Hardness: 50 # 862 // 3 levels - FTF - all negative numbers - not sure they will be able to solve this correctly Selection.if.Multiple ? Selection.if.{Condition.Relational.{true,false},ifClause.{Simple,Compound}} > {(){=;=;if( + > 0){<<; <<;} if( - < 0) << ; if( * > 0) {<<; <<;}}} // {(){=;=;if( + > 0){<<;} if( - < 0) << ; if( * > 0) {<<; <<;}}} // Simplified for S08 > Type: output Hardness: 50 //Errors - If/Else Statements // {(){=;;if( > 0){;<<<;<<;}}} // {(){=;=;if( == ){<<'T';}else{;<<;}}} // {(){=;if( == 100){< == 0){<;<<;}}}} //Errors - If Statements // {(){=;if( > 0){=;}<<;}} // {(){=;;if( > 100){<<;}}} // {(){=;if( == ){;<<;}}} //Code Ok - If/Else Statements // {(){=;if( > 0){<<;}else{<<'E';}=;if( < 100){<<;}else{<<;}}} // {(){=;if( > 0){<;}}} // {(){=;=;if( > ){<<;}else{<<;}}} // {(){=;if( < -100){<<'T';}else{<<'F';}}} // {(){=;if( == ){<<;}else{<<;}}} // {(){=;if( > 0){<<;}else{if( < -500){<<'L';}else{<<'H';}}}} // ------------------ Parsons Puzzles -------------------------------------------------------- // Learning objectives: // Selection.ifElse.Parsons.Single.Simple - 2000 // Braces provided any way, but can be ignored by the student // Selection.ifElse.Parsons.Single.Compound - 2025 // Braces cannot be ignored by the student // Selection.ifElse.Parsons.Multiple.Simple - 2050 // Braces provided any way, but can be ignored by the student // Selection.ifElse.Parsons.Multiple.Compound - 2075 // Braces cannot be ignored by the student // Selection.ifElse.Parsons.Nested.Cascading.Simple - 2100 // Braces provided any way, but can be ignored by the student // Selection.ifElse.Parsons.Nested.Cascading.Compound - 2125 // Braces cannot be ignored by the student // Selection.ifElse.Parsons.Nested.Taxonomic.Simple - 2150 // Braces provided any way, but can be ignored by the student // Selection.ifElse.Parsons.Nested.Taxonomic.Compound - 2175 // Braces cannot be ignored by the student // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Single.Simple - 2000 // One input: 2000-; Two inputs: 2005- // DemoParsons // Prints whether the number is odd or even # 2000 Selection.ifElse.Parsons.Single.Simple > "It reads a number and prints whether it is odd or even." {(){ /* Declare */ ; /* Read */ << "Enter the number"; >> ; /* Compute and print whether is odd or even */ if( % 2 == 0) {<< << " is even";} else {<< << " is odd";}}} > Type: parsons Hardness: 20 // Read sound in decibels, prints loud if over 85 decibels # 2001 Selection.ifElse.Parsons.Single.Simple > "It reads sound in decibels, and prints whether it is loud (if over 85 decibels) or tolerable." {(){ /* Declare */ ; /* Read */ << "Enter the loudness of sound in decibels"; >> ; /* Compute and print whether the sound is loud (over 85) or tolerable */ if( > 85 ) {<< "Sound is loud";} else {<< "Sound is tolerable";}}} > Type: parsons Hardness: 20 // Read temperature, print has fever if over 98.6 and no fever otherwise # 2002 Selection.ifElse.Parsons.Single.Simple > "It reads body temperature in celsius, and prints whether the person has fever (if over 37) or is normal." {(){ /* Declare */ ; /* Read */ << "Enter the body temperature in celsius"; >> ; /* Compute and print whether the person has fever (over 37) or is normal */ if( > 37 ) {<< "Person has fever";} else {<< "Person is normal";}}} > Type: parsons Hardness: 20 // Pretest // Print the smaller number # 2005 Selection.ifElse.Parsons.Single.Simple > "It reads two numbers and prints the smaller value among them." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the first value"; >> ; /* Read */ << "Enter the second value"; >> ; /* If is less than , print . Otherwise, print */ if( < ){<< ;} else {<< ;}}} > Type: parsons Hardness: 30 // Prints buy if the price to earnings ratio is 19 or less, and sell otherwise # 2006 Selection.ifElse.Parsons.Single.Simple > "It reads the price and earnings of a stock. It recommends buying the stock if the price to earnings ratio is 19 or less, and selling otherwise." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the price of the stock"; >> ; /* Read */ << "Enter the earnings of the stock"; >> ; /* Compute and print the smaller value of and */ if( / <= 19.0 ){<< "Buy the stock";} else {<< "Sell the stock";}}} > Type: parsons Hardness: 30 // Posttest // Reads two numbers, and prints whether the second is a factor in the first # 2007 Selection.ifElse.Parsons.Single.Simple > "It reads two numbers and prints whether or not the second number is a factor of the first." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the first number"; >> ; /* Read */ << "Enter the second number"; >> ; /* Compute and print whether evenly divides */ if( % == 0 ){<< << " is a factor of " << ;} else {<< << " is NOT a factor of " << ;}}} > Type: parsons Hardness: 30 // Compute and print the absolute difference # 2008 Selection.ifElse.Parsons.Single.Simple > "It reads two numbers and prints the absolute difference between them." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the first number"; >> ; /* Read */ << "Enter the second number"; >> ; /* Compute and print whether evenly divides */ if( > ){ = - ;} else { = - ;} /* Print */ << ; }} > Type: parsons Hardness: 35 // Based on atomic weight, print whether noble metal/rare earth/ etc. // // Used to test whether we correctly figure out which braces are optional. // # 2002 // Selection.ifElse.Parsons.Single.Simple // > // "It reads a number and prints whether it is odd or even." // {(){ // /* Declare */ // = ; // /* Compute and print */ // if( != 2 ) // { << "Nested1"; << "Nested2"; } // else // // { if( > 0 ){ << "Nested1"; << "Nested2"; << "Nested3"; } } // { if( > 0 ){ << "Positive"; } else { << "Negative"; } } // }} // > // Type: parsons // Hardness: 20 // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Single.Compound - 2025 // Converting from military hour to civilian hour # 2025 Selection.ifElse.Parsons.Single.Compound ? Selection.ifElse.Parsons.Single.Simple > "It reads military hour (0-23) and prints corresponding civilian hour (12 AM - 12PM)." {(){ /* Declare */ ; /* Read */ << "Enter the military hour"; >> ; /* Compute and print civilian hour */ if( < 12) { if( 0 == ) { << "12"; } else { << ; } << " AM";} else { if( > 12 ) { << - 12; } else { << "12"; } << " PM";}}} > Type: parsons Hardness: 50 // celsius to fahrenheit? from unit, to unit.. // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Multiple.Simple - 2050 // ice cream or yogurt, cup or cone // positive shallow slope # 2050 Selection.ifElse.Parsons.Multiple.Simple ? Selection.ifElse.Parsons.Single.Simple > "It reads the slope of a line and prints whether it is positive or negative and shallow (less than 45 degrees) or steep." {(){ /* Declare */ ; /* Read */ << "Enter the slope"; >> ; /* Compute and print whether it is positive or negative */ if( >= 0) { << "Slope is positive, "; } else { << "Slope is negative, "; } /* Compute and print whether it is shallow (less than 45 degrees) or steep */ if( < 45 ) { << "shallow"; } else { << "steep"; } }} > Type: parsons Hardness: 20 // Grade A/B/C/D and + or - // suit and face of a card - multiple nested, though! // face card versus pip card (<= 10) black suit (c,s) versus red suit // print north/south based on latitude and east/west based on longitude // Actually, suitable for if.Parsons.Multiple.simple // Smallest of 3 numbers: min is smaller of a and b. if min less than c, print min, else c // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Multiple.Compound - 2075 // two sets of inputs? // pressure = force / area convert from british to metric units? // // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Nested.Cascading.Simple - 2100 // 4: 2100; 5: 2105; 7: 2110 // 4 // Month -> Season # 2100 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads the month and prints the corresponding season: Winter (January-March), Spring (April-June), Summer (July-September) and Fall otherwise)." {(){ /* Declare */ ; /* Read */ << "Enter the number of the month (1-12)"; >> ; /* Compute and print the season based on */ if( <= 3) {<< "Season is winter (January-March)";} else{ if( <= 6) {<< "Season is spring (April-June)";} else{ if( <= 9) {<< "Season is summer (July-September)";} else {<< "Season is fall (October-December)";}}}}} > Type: parsons Hardness: 20 // DemoParsons // 4 // Degrees and quadrants # 2101 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads location in degrees and prints the corresponding quadrant: First (1-90), Second (91-180), Third (181-270) and Fourth otherwise." {(){ /* Declare */ ; /* Read */ << "Enter the location in degrees (1-360)"; >> ; /* Compute and print the quadrant based on */ if( <= 90) {<< "First quadrant";} else{ if( <= 180) {<< "Second quadrant";} else{ if( <= 270) {<< "Third quadrant";} else {<< "Fourth quadrant";}}}}} > Type: parsons Hardness: 20 // Pretest // 5 // numerical to letter grade - integer # 2105 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads numerical grade, converts it to letter grade - A (90 and up), B (80-89), C (70-79), D (55-69) and F otherwise - and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the numerical grade"; >> ; /* Compute based on */ if( >= 90) { = 'A';} else{ if( >= 80) { = 'B';} else{ if( >= 70) { = 'C';} else{ if( >= 55) { = 'D';} else{ = 'F';}}}} /* Print */ << ; }} > Type: parsons Hardness: 30 // Posttest // 5 // Prints the status of a student based on the number of credits # 2106 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads the number of credits earned by a student and prints the status of the student: freshman (0-28), sophomore (29-56), junior (57-84) senior (85-128) and graduate (129-)." {(){ /* Declare */ ; /* Read */ << "Enter the credits earned by the student"; >> ; /* Compute and print the status of the student */ if( >= 129 ) { << "Status is graduate (over 128 credits)"; } else { if( >= 85 ) { << "Status is senior (85-128 credits)"; } else { if( >= 57 ) { << "Status is junior (57-84 credits)"; } else { if( >= 29 ) { << "Status is sophomore (29-56 credits)"; } else { << "Status is freshman (0-28 credits)"; }}}} }} > Type: parsons Hardness: 30 // 5 // 440 miles and up: Exosphere, 50 miles and up thermosphere, // 31 miles and up is mesosphere, 7 miles and up is stratosphere and otherwise, troposphere // 0-12, 12-50, 50-80, 80-700, 700-10,000 in km all approx // Prints name of atmospheric layer # 2107 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads the altitude in miles and prints the name of the atmospheric layer at that altitude: troposphere (0 - 7), stratosphere (8 - 30), mesosphere (31 - 50), thermosphere (51 - 440) and exosphere (over 440)." {(){ /* Declare */ ; /* Read */ << "Enter the altitude"; >> ; /* Compute and print the name of the atmospheric layer */ if( <= 7 ) { << "Troposphere (0-7 miles)"; } else { if( <= 30 ) { << "Stratosphere (8-30 miles)"; } else { if( <= 50 ) { << "Mesosphere (31-50 miles)"; } else { if( <= 440 ) { << "Thermosphere (51-440 miles)"; } else { << "Exosphere (over 440 miles)"; }}}}}} > Type: parsons Hardness: 30 // 6 // Frequencies and colors (in reverse order of VBGYOR) # 2110 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads wavelength of light and prints the corresponding color: violet, blue, green, yellow, orange or red." {(){ /* Declare */ ; /* Read */ << "Enter the wavelength in nanometers"; >> ; /* Compute and print the color corresponding to the wavelength */ if( <= 450 ) { << "Color is violet (380-450 nm)"; } else { if( <= 495 ) { << "Color is blue (450-495 nm)"; } else { if( <= 570 ) { << "Color is green (495-570 nm)"; } else { if( <= 590 ) { << "Color is yellow (570-590 nm)"; } else { if( <= 620 ) { << "Color is orange (590-620 nm)"; } else { << "Color is red (620-750 nm)"; } }}}}}} > Type: parsons Hardness: 40 // 7 // Prints enhanced Fujita scale # 2111 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads wind speed (mph), computes and prints enhanced Fujita Hurricane scale corresponding to it: F0 (40-72), F1 (73-112), F2 (113-157), F3 (158-206), F4 (207-260) and F5 (261-)." {(){ /* Declare */ ; /* Read */ << "Enter the wind speed in miles per hour"; >> ; /* Compute and print the Fujita scale corresponding to wind speed */ if( >= 261 ) { << "Scale is F5 (over 260 mph)"; } else { if( >= 207 ) { << "Scale is F4 (207-260 mph)"; } else { if( >= 158 ) { << "Scale is F3 (158-206 mph)"; } else { if( >= 113 ) { << "Scale is F2 (113-157 mph)"; } else { if( >= 73 ) { << "Scale is F1 (73-112 mph)"; } else { if( >= 40 ) { << "Scale is F0 (40-72 mph)"; } else { << "Not a hurricane"; } }}}}} }} > Type: parsons Hardness: 40 // 8 oz is smal,, 12 is medium, 16 is large, over 16 is extra large // PROBLEMS THAT NEED AN ALGORITHM - OTHERWISE, ORDER IS NOT FIXED // Leap year # 2115 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It reads a year and prints whether it is a leap year or not." {(){ /* Declare */ ; /* Read */ << "Enter the year"; >> ; /* If is not divisible by 4, it is not a leap year */ if( % 4 != 0 ) { << "Not leap year"; } else { /* If is divisible by 4, but not by 100, it is a leap year */ if( % 100 != 0 ) { << "Leap year"; } else { /* If is divisible by 4 and 100, but not by 400, it is a leap year. Otherwise, it is not. */ if( % 400 == 0 ) { << "Leap year"; } else { << "Not leap year"; } }}}} > Type: parsons Hardness: 20 // calculator: 1 to add, 2 to subtract, 3 to multiply and 4 to divide - real - order not important # 2116 Selection.ifElse.Parsons.Nested.Cascading.Simple > "It implements a calculator: It reads two numbers and an operation (+/-/*/%), applies the operation to the two numbers and prints the result." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the first number"; >> ; /* Read */ << "Enter the second number"; >> ; /* Read */ << "Enter + to add, - to subtract, * to multiply and / to divide"; >> ; /* Compute by adding and */ if('+' == ) { = + ;} else{ /* Compute by subtracting from */ if('-' == ) { = - ;} else{ /* Compute by multipying by */ if('*' == ) { = * ;} else{ /* Compute by dividing by */ = / ;}}} /* Print */ << ; }} > Type: parsons Hardness: 20 // Reads character suit of a card, prints its name // name of coin // name of month // pH of 1-6 is acidic, 7 is neutral and 8-14 is basic // types of plastic 1-6 // 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 // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Single.Cascading.Compound - 2125 // // mega, giga, after dividing by powers of 10 // # 2125 // Selection.ifElse.Parsons.Nested.Cascading.Compound // > // "It reads the size of memory in bytes, divides by appropriate power of 10 and prints it with appropriate units: bytes (less than 1000), Kilobytes (up to a million), Megabyte (up to a billion), and Gigabyte (above a billion)." // {(){ // /* Declare */ // ; // /* Read */ // << "Enter the size of the memory in bytes"; // >> ; // /* Compute and print the size of memory with units */ // if( <= 1000 ) // { << ; << " bytes"; } // else { // if( <= 1000000 ) // { << / 1000; << " Kilobytes"; } // else { // if( <= 1000000000 ) // { << / 1000000; << " Megabytes"; } // else { // { << / 1000000000; << " Gigabytes"; }}}}}} // > // Type: parsons // Hardness: 20 // federal taxes : rate, deduction // Similary, up to -3: milli, micro, nano, pico, femto, alto.. // credit card: silver, gold, platinum, black - annual fees, interest rate, mini payment // NEED ALGORITHM // tuition: per credit, fees? // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Single.Taxonomic.Simple - 2150 // smallest of 3 numbers - order not important # 2150 Selection.ifElse.Parsons.Nested.Taxonomic.Simple > "It reads 3 numbers and computes the smallest of the three and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the first number"; >> ; /* Read */ << "Enter the second number"; >> ; /* Read */ << "Enter the third number"; >> ; /* If is greater than */ if( > ) { /* If is greater than , is smallest. Otherwise, is smallest */ if( > ) { = ; } else { = ; } } else { /* If is greater than , is smallest. */ if( > ) { = ; } else { /* If is greater than , is smallest. Otherwise, is smallest */ if( > ) { = ; } else { = ; } } } /* Print */ << ; }} > Type: parsons Hardness: 20 // -------------------------------------------------------------------------------------------- // Selection.ifElse.Parsons.Nested.Taxonomic.Compound - 2175 // [, ] # 2175 Selection.ifElse.Parsons.Nested.Taxonomic.Compound > "Re-assemble the following code. If the value of is less than , it must print the sum of and . Otherwise, it must print the difference of and ." {(){=; if( < ){ = + ;}else { = - ;} << ;}} > Type: parsons Hardness: 20 // -------------------------------------------------------------------------- // 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: output Hardness: 10 // How to enter multiple outputs # 91 Demonstration > [,]{(){=;<<;=;<<;<< - ;}} > Type: output Hardness: 10 // How to enter NO output # 92 Demonstration > {(){=;=;; = + ;}} > Type: output Hardness: 10 // --------------------------------------------------------------------------