// 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: cloze Hardness: 10 // Declaration statement # 111 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Declare of type ^;^ = ;<<;}} > Type: cloze Hardness: 10 // Initialization value # 112 Program.Control.Sequence.Simple Statement > {(){=^Initialization Value^^;<<;}} > Type: cloze Hardness: 10 // Initialization statement # 113 Program.Control.Sequence.Simple Statement > {(){^Declare of type and initialize it to ^=;^<<;}} > Type: cloze Hardness: 10 // Assignment Value # 114 Program.Control.Sequence.Simple Statement > {(){; = ^Assignment Value^^;<<;}} > Type: cloze Hardness: 10 // Assignment Statement # 115 Program.Control.Sequence.Simple Statement > {(){;^Assign to ^ = ;^<<;}} > Type: cloze Hardness: 10 // Declaration + Assignment Statement # 116 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Assign to ^ = ;^<<;}} > Type: cloze Hardness: 10 // Declaration + Assignment Statement # 117 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Assign to ^ = ;^<<;^Increment ^ = + 1;^<<;}} > Type: cloze Hardness: 10 // Declaration + Assignment Statement # 118 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Assign to ^ = ;^<<;^Double value of ^ = + ;^<<;}} > Type: cloze Hardness: 10 // Combination of variables - expressions # 120 Program.Control.Sequence.Simple Statement > {(){=;=;; = ^Sum of and ^ + ^;<<;}} > Type: cloze Hardness: 20 // Combination of variables - expressions # 121 Program.Control.Sequence.Simple Statement > {(){=;=;; = ^Product of and ^ * ^;<<;}} > Type: cloze Hardness: 20 // Combination of variables - expressions # 122 Program.Control.Sequence.Simple Statement > {(){=;=;; = ^Remainder of dividing by ^ % ^;<<;}} > Type: cloze Hardness: 20 // Combination of variables - expressions # 123 Program.Control.Sequence.Simple Statement > {(){^Declare of type ^;^^Declare of type ^;^^Input ^>> ;^ ^Assign * to ^ = * ;^^Print ^<< ;^}} > Type: cloze Hardness: 20 // Combination of variables - expressions # 500 Program.Control.Selection.ifElse.Condition.Relational.true > {(){=;=;;if( < ) { << ; = ; << ; } else { << ; = ; << ; } << ; }} > Type: refactor Hardness: 20 // Testing variable name recommendations # 897 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: income Type: real */^^;^ /* [2] Statement: Declare Purpose: days Type: whole number */^^;^ /* [3] Statement: Declare Purpose: expenses Type: real */^^;^ /* [4] Statement: Declare Purpose: age of insured Type: whole number */^^;^ /* [5] Statement: Declare Purpose: interest rate Type: real */^^;^ /* [6] Statement: Declare Purpose: minimum limit Type: whole number */^^;^ }} > Type: code Hardness: 20 // THIS DOES NOT WORK - VARIABLES DECLARED AS PART OF THE PROGRAM SHOW UP AS UNKNOWN! in FEEDBACK // BECAUSE STUDENTSYMBOLTABLE IS NOT AWARE OF THEM // Testing feedback provided by expressions # 898 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ ; ; ; << "Enter first operand"; >> ; << "Enter second operand"; >> ; /* [1] Statement: Compute Purpose: result BasedOn: sum of the two operands */^^ = + ;^ << ; /* [2] Statement: Compute Purpose: result BasedOn: difference of the two operands */^^ = - ;^ << ; /* [3] Statement: Compute Purpose: result BasedOn: product of the two operands */^^ = * ;^ << ; /* [4] Statement: Compute Purpose: result BasedOn: division of the two operands */^^ = / ;^ << ; /* [5] Statement: Compute Purpose: result BasedOn: remainder of the two operands */^^ = % ;^ << ; }} > Type: code Hardness: 20 // Testing feedback provided by expressions # 899 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: first operand Name: Type: whole number */^^;^ /* [2] Statement: Declare Purpose: second operand Name: Type: whole number */^^;^ /* [3] Statement: Declare Purpose: result Name: Type: whole number */^^;^ << "Enter first operand"; >> ; << "Enter second operand"; >> ; /* [4] Statement: Compute Purpose: result BasedOn: sum of the two operands */^^ = + * ;^ << ; /* [5] Statement: Compute Purpose: result BasedOn: difference of the two operands */^^ = - * ;^ << ; /* [6] Statement: Compute Purpose: result BasedOn: product of the two operands */^^ = * ;^ << ; /* [7] Statement: Compute Purpose: result BasedOn: division of the two operands */^^ = / ;^ << ; /* [8] Statement: Compute Purpose: result BasedOn: remainder of the two operands */^^ = % ;^ << ; }} > Type: code Hardness: 20 // ---------------------------Subtraction------------------------------------------- // Calculate balance of income - expenses # 900 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: income Name: Type: real */^^;^ /* [4] Statement: Declare Purpose: expenses Name: Type: real */^^;^ /* [7] Statement: Declare Purpose: balance Name: Type: real */^^;^ /* [2-1] Statement: Prompt Purpose: income Format: Enter income */^^<< "Enter income";^ /* [3-2] Statement: Input Purpose: income */^^>> ;^ /* [5-4] Statement: Prompt Purpose: expenses Format: Enter expenses */^^<< "Enter expenses";^ /* [6-5] 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 // ---------------------------Multiplication------------------------------------------- // Calculate the interest on a loan # 925 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: principal Name: Type: real */^^;^ /* [4] Statement: Declare Purpose: interest rate Name: Type: real */^^;^ /* [7] Statement: Declare Purpose: interest Name: Type: real */^^;^ /* [2-1] Statement: Prompt Purpose: principal Format: Enter principal */^^<< "Enter principal";^ /* [3-2] Statement: Input Purpose: principal */^^>> ;^ /* [5-4] Statement: Prompt Purpose: interest rate Format: Enter interest rate */^^<< "Enter interest rate";^ /* [6-5] 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 // Input hourly rate, number of hours, compute total pay # 926 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: hourly rate Name: Type: real */^^;^ /* [4] Statement: Declare Purpose: number of hours Name: Type: real */^^;^ /* [7] Statement: Declare Purpose: total pay Name: Type: real */^^;^ /* [2] Statement: Prompt Purpose: hourly rate Format: Enter hourly rate */^^<< "Enter hourly rate";^ /* [3-2,1] Statement: Input Purpose: hourly rate */^^>> ;^ /* [5] Statement: Prompt Purpose: number of hours Format: Enter 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 // Calculate volume of cube of length, width and height - all ints # 927 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: length Name: Type: whole number */^^;^ /* [4] Statement: Declare Purpose: width Name: Type: whole number */^^;^ /* [7] Statement: Declare Purpose: height Name: Type: whole number */^^;^ /* [10] Statement: Declare Purpose: volume Name: Type: whole number */^^;^ /* [2-1] Statement: Prompt Purpose: length Format: Enter length */^^<< "Enter length";^ /* [3-2] Statement: Input Purpose: length */^^>> ;^ /* [5-4] Statement: Prompt Purpose: width Format: Enter width */^^<< "Enter width";^ /* [6-5] Statement: Input Purpose: width */^^>> ;^ /* [8-7] Statement: Prompt Purpose: height Format: Enter height */^^<< "Enter height";^ /* [9-8] 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 // ---------------------------Division------------------------------------------- // Calculate the shares bought # 925 Program.Control.Sequence.Simple Statement > {/* Define main function */(){ /* [1] Statement: Declare Purpose: investment Name: Type: real */^^;^ /* [4] Statement: Declare Purpose: share price Name: Type: real */^^;^ /* [7] Statement: Declare Purpose: number of shares Name: Type: real */^^;^ /* [2-1] Statement: Prompt Purpose: investment Format: Enter investment */^^<< "Enter investment";^ /* [3-2] Statement: Input Purpose: investment */^^>> ;^ /* [5-4] Statement: Prompt Purpose: share price Format: Enter price per share */^^<< "Enter price per share";^ /* [6-5] Statement: Input Purpose: share price */^^>> ;^ /* [8-3,6,7] Statement: Compute Purpose: number of shares BasedOn: dividing investment by share price */^^ = / ;^ /* [9-8] Statement: Output Purpose: number of shares */^^<< ;^ }} > Type: code Hardness: 20 // ---------------------------Remainder------------------------------------------- // NEED A WAY TO SAY CHANGE = CHANGE % 25 CAN ALSO BE WRITTEN AS CHANGE = CHANGE - NUMQUARTERS * 25 // Number of quarters, dimes, nickels and pennies in change # 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 // ---------------------------Parentheses------------------------------------------- // NOT SURE OF PARENTHESES GRADING YET // 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 // /* [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 // // To test character data type - IT WORKS!! // # 903 // Program.Control.Sequence.Simple Statement // ? // Program.Control.Sequence.Simple Statement // > // "It reads numerical grade, converts it to letter grade (90 and up is A, 80-89 is B, 70-79 is D, 55-69 is D and F otherwise) and prints it." // {(){ // /* Declare */ // ; // /* Declare */ // ; // /* Read */ // = ; // /* Compute based on */ // if( >= 90){ = 'A';}else{if( >= 80){ = 'B';}else{if( >= 70){ = 'C';}else{if( >= 55){ = 'D';}else{ = 'F';}}} } // /* Print */ // << ; // } // > // Type: output // Hardness: 20