// In multi-step loops, does not handle condition parameter correctly // Does not yet handle assignment operators // What about () in student code? actual template? // Use this file to test new templates // *********************For Loop********************************************* // Only the loop parameters, upcounting, by 1 # 100 Program.Control.Sequence.Compound Statement > {(){;for( = ^Initialization Value^^; < ^Comparison Value^^; = + ^Update Value^1^){<<;}}} > Type: cloze Hardness: 20 // PROBLEM: STUDENTS CAN ENTER ANY OF SEVERAL VALUES FOR CONDITION - SO GRADING HAS TO BE SMARTER // Only the loop parameters, upcounting, by many # 101 Program.Control.Sequence.Compound Statement > {(){;for( = ^Initialization Value^^; < ^Comparison Value^^; = + ^Update Value^^){<<;}}} > Type: cloze Hardness: 20 // Only the loop parameters, downcounting, by 1 # 102 Program.Control.Sequence.Compound Statement > {(){;for( = ^Initialization Value^^; > ^Comparison Value^^; = - ^Update Value^1^){<<;}}} > Type: cloze Hardness: 20 // Only the loop parameters, downcounting, by many # 103 Program.Control.Sequence.Compound Statement > {(){;for( = ^Initialization Value^^; >= ^Comparison Value^^; = - ^Update Value^^){<<;}}} > Type: cloze Hardness: 20 // Entire loop header statements, upcounting, by 1 # 105 Program.Control.Sequence.Compound Statement > {(){;for(^Initialize to ^ = ^;^Condition^ < ^;^Update ^ = + 1^){<<;}}} > Type: cloze Hardness: 40 // Entire loop header statements, upcounting, by many # 106 Program.Control.Sequence.Compound Statement > {(){;for(^Initialize to ^ = ^;^Condition^ < ^;^Update ^ = + ^){<<;}}} > Type: cloze Hardness: 40 // Entire loop header statements, downcounting, by 1 # 107 Program.Control.Sequence.Compound Statement > {(){;for(^Initialize to ^ = ^;^Condition^ > ^;^Update ^ = - 1^){<<;}}} > Type: cloze Hardness: 40 // Entire loop header statements, downcounting, by many # 108 Program.Control.Sequence.Compound Statement > {(){;for(^Initialize to ^ = ^;^Condition^ > ^;^Update ^ = - ^){<<;}}} > Type: cloze Hardness: 40 # 109 Program.Control.Sequence.Compound Statement > {(){;^Write control^for^( = ; < ; = + 1){<<;}}} > Type: cloze Hardness: 20 // ****************************Variables**************************************************** // Declaration type # 110 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^^; = ;<<;}} > Type: output Hardness: 10 // Declaration statement # 111 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^ = ;<<;}} > Type: output Hardness: 10 // Initialization value # 112 Program.Control.Sequence.Simple Statement > {(){=^Initialization Value^^;<<;}} > Type: output Hardness: 10 // Initialization statement # 113 Program.Control.Sequence.Simple Statement > {(){^Declare of type and initialize it to ^=;^<<;}} > Type: output Hardness: 10 // Assignment Value # 114 Program.Control.Sequence.Simple Statement > {(){; = ^Assignment Value^^;<<;}} > Type: output Hardness: 10 // Assignment Statement # 115 Program.Control.Sequence.Simple Statement > {(){;^Assign to ^ = ;^<<;}} > Type: output Hardness: 10 // Declaration + Assignment Statement # 116 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Assign to ^ = ;^<<;}} > Type: output Hardness: 10 // Declaration + Assignment Statement # 117 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Assign to ^ = ;^<<;^Increment ^ = + 1;^<<;}} > Type: output Hardness: 10 // Declaration + Assignment Statement # 118 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Assign to ^ = ;^<<;^Double value of ^ = + ;^<<;}} > Type: output Hardness: 10 // Combination of variables - expressions # 120 Program.Control.Sequence.Simple Statement > {(){=;=;; = ^Sum of and ^ + ^;<<;}} > Type: output Hardness: 20 // Combination of variables - expressions # 121 Program.Control.Sequence.Simple Statement > {(){=;=;; = ^Product of and ^ * ^;<<;}} > Type: output Hardness: 20 // Combination of variables - expressions # 122 Program.Control.Sequence.Simple Statement > {(){=;=;; = ^Remainder of dividing by ^ % ^;<<;}} > Type: output Hardness: 20 // Calculate the interest on a loan # 900 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: principal Type: real */^^;^ /* [4] Statement: Declare Purpose: interest rate Type: real */^^;^ /* [7] Statement: Declare Purpose: interest Type: real */^^;^ /* [2] Statement: Prompt Purpose: principal */^^<< "Enter principal";^ /* [3-2,1] Statement: Input Purpose: principal */^^>> ;^ /* [5] Statement: Prompt Purpose: interest rate */^^<< "Enter interest rate";^ /* [6-5,4] Statement: Input Purpose: interest rate */^^>> ;^ /* [8-3,6,7] Statement: Compute Purpose: interest BasedOn: product of principal and interest rate */^^ = * ;^ /* [9-8] Statement: Output Purpose: interest */^^<< ;^ }} > Type: code Hardness: 20 // Calculate average temperature given min and max # 901 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: minimum temperature Type: whole number */^^;^ /* [4] Statement: Declare Purpose: maximum temperature Type: whole number */^^;^ /* [7] Statement: Declare Purpose: average temperature Type: real */^^;^ /* [2] Statement: Prompt Purpose: minimum temperature */^^<< "Enter minimum temperature";^ /* [3-2,1] Statement: Input Purpose: minimum temperature */^^>> ;^ /* [5] Statement: Prompt Purpose: maximum temperature */^^<< "Enter maximum temperature";^ /* [6-5,4] Statement: Input Purpose: maximum temperature */^^>> ;^ /* [8-3,6,7] Statement: Compute Purpose: average temperature BasedOn: sum of minimum temperature and maximum temperature divided by 2 */^^ = ( + ) / 2;^ /* [9-8] Statement: Output Purpose: average temperature */^^<< ;^ }} > Type: code Hardness: 20 // Number of quarters, dimes, nickels and pennies in change // Need a way to say change = change % 25 can also be written as change = change - numQuarters * 25 # 902 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: change Type: whole number */^^;^ /* [4] Statement: Declare Purpose: number of quarters Type: whole number */^^;^ /* [7] Statement: Declare Purpose: number of dimes Type: whole number */^^;^ /* [10] Statement: Declare Purpose: number of nickels Type: whole number */^^;^ /* [12] Statement: Declare Purpose: number of pennies Type: whole number */^^;^ /* [14] Statement: Declare Purpose: copy of change Type: whole number */^^;^ /* [2] Statement: Prompt Purpose: change */^^<< "Enter change";^ /* [3-2,1] Statement: Input Purpose: change */^^>> ;^ /* [15-14] Statement: Compute Purpose: copy of change BasedOn: change */^^ = ;^ /* [5-4,3] Statement: Compute Purpose: number of quarters BasedOn: number of times 25 divides change */^^ = / 25;^ /* [6-5] Statement: Compute Purpose: remaining change BasedOn: remainder after 25 divides change */^^ = % 25;^ /* [8-7,6] Statement: Compute Purpose: number of dimes BasedOn: number of times 10 divides change */^^ = / 10;^ /* [9-8] Statement: Compute Purpose: remaining change BasedOn: remainder after 10 divides change */^^ = % 10;^ /* [11-10,9] Statement: Compute Purpose: number of nickels BasedOn: number of times 5 divides change */^^ = / 5;^ /* [13-12,11] Statement: Compute Purpose: number of pennies BasedOn: remainder after 5 divides change */^^ = % 5;^ /* [16-15] Statement: Output Purpose: copy of change Format: c cents = */^^<< << "cents =";^ /* [17-16,13] Statement: Output Purpose: number of quarters Format: q quarters */^^<< << "quarters";^ /* [18-16,13] Statement: Output Purpose: number of dimes Format: d dimes */^^<< << "dimes";^ /* [19-16,13] Statement: Output Purpose: number of nickels Format: n nickels */^^<< << "nickels";^ /* [20-16,13] Statement: Output Purpose: number of pennies Format: p pennies */^^<< << "pennies";^ }} > Type: code Hardness: 20 // Calculate volume of cube of length, width and height - all ints # 903 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: length Type: whole number */^^;^ /* [4] Statement: Declare Purpose: width Type: whole number */^^;^ /* [7] Statement: Declare Purpose: height Type: whole number */^^;^ /* [10] Statement: Declare Purpose: volume Type: whole number */^^;^ /* [2] Statement: Prompt Purpose: length */^^<< "Enter length";^ /* [3-2,1] Statement: Input Purpose: length */^^>> ;^ /* [5] Statement: Prompt Purpose: width */^^<< "Enter width";^ /* [6-5,4] Statement: Input Purpose: width */^^>> ;^ /* [8] Statement: Prompt Purpose: height */^^<< "Enter height";^ /* [9-8,7] Statement: Input Purpose: height */^^>> ;^ /* [11-3,6,9,10] Statement: Compute Purpose: volume BasedOn: product of length, width and height */^^ = * * ;^ /* [12-11] Statement: Output Purpose: volume */^^<< ;^ }} > Type: code Hardness: 20 // Calculate balance of income - expenses # 904 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: income Type: real */^^;^ /* [4] Statement: Declare Purpose: expenses Type: real */^^;^ /* [7] Statement: Declare Purpose: balance Type: real */^^;^ /* [2] Statement: Prompt Purpose: income */^^<< "Enter income";^ /* [3-2,1] Statement: Input Purpose: income */^^>> ;^ /* [5] Statement: Prompt Purpose: expenses */^^<< "Enter expenses";^ /* [6-5,4] Statement: Input Purpose: expenses */^^>> ;^ /* [8-3,6,7] Statement: Compute Purpose: balance BasedOn: difference of income and expenses */^^ = - ;^ /* [9-8] Statement: Output Purpose: balance */^^<< ;^ }} > Type: code Hardness: 20 // Input hourly rate, number of hours, compute total pay # 905 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: hourly rate Type: real */^^;^ /* [4] Statement: Declare Purpose: number of hours Type: real */^^;^ /* [7] Statement: Declare Purpose: total pay Type: real */^^;^ /* [2] Statement: Prompt Purpose: hourly rate */^^<< "Enter hourly rate";^ /* [3-2,1] Statement: Input Purpose: hourly rate */^^>> ;^ /* [5] Statement: Prompt Purpose: number of hours */^^<< "Enter number of hours";^ /* [6-5,4] Statement: Input Purpose: number of hours */^^>> ;^ /* [8-3,6,7] Statement: Compute Purpose: total pay BasedOn: product of hourly rate and number of hours */^^ = * ;^ /* [9-8] Statement: Output Purpose: total pay */^^<< ;^ }} > Type: code Hardness: 20 // /* [4] Statement: Declare Purpose: interest rate Type: real Value: */^^;^ // /* If interest is more than 100, print 'expensive', else 'cheap' */if( ^[9.1]Condition^ > 100^ ){ ^[9.2]^<< ;^}else{^[9.3]^<< ;^} // Template for testing only # 999 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: quantity Type: whole number Value: */^^ = ;^ /* [2] Statement: Declare Purpose: quantity Type: whole number Value: */^^ = ;^ /* [3-1,2] Statement: Compute Purpose: increment quantity */^^ = + 1;^ /* [4-3] Statement: Output Purpose: quantity */^^<< ;^ }} > Type: code Hardness: 20