// 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 / parsons // 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 // ------------------------------------------------------------------------------- // The actual learning objectives: // 2000 // Sequence.Parsons.Single // 2025 // Sequence.Parsons.Tandem // // Input-Compute-Output-Dependent Input-Compute-Output // 2050 // Sequence.Parsons.Hidden // Input-ComputeHidden-Compute-Output // ---------------------------Addition------------------------------------------- // Calculate total as sum of cost and tax # 2000 Sequence.Parsons > "It reads the cost of an item and tax, calculates the sum of the two and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the cost of the item"; >> ; /* Read */ << "Enter the tax to be paid"; >> ; /* Calculate as sum of and */ = + ; /* Print */ << ;}} > Type: parsons Hardness: 20 // Calculate the total duration as the duration of the move and trailers # 2001 Sequence.Parsons > "It reads the duration of the movie and trailers, calculates their sum and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the duration of the movie"; >> ; /* Read */ << "Enter the duration of the previews"; >> ; /* Calculate as the sum of and */ = + ; /* Print */ << ;}} > Type: parsons Hardness: 20 // ---------------------------Subtraction------------------------------------------- // Calculate balance of income - expenses # 2005 Sequence.Parsons > "It reads income, and expenses, calculates the balance and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter income"; >> ; /* Read */ << "Enter expenses"; >> ; /* Calculate as difference of and */ = - ; /* Print */ << ;}} > Type: parsons Hardness: 20 // Calculate payment as cost - discount/rebate # 2006 Sequence.Parsons > "It reads the price of an item and discount, calculates their difference and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter price"; >> ; /* Read */ << "Enter discount"; >> ; /* Calculate as difference of and */ = - ; /* Print */ << ;}} > Type: parsons Hardness: 20 // ---------------------------Multiplication------------------------------------------- // DemoParsons # 2010 Sequence.Parsons > "It reads the size of a rectangular room, calculates its area and prints the area." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the first dimension"; >> ; /* Read */ << "Enter the second dimension"; >> ; /* Calculate as product of and */ = * ; /* Print */ << ;}} > Type: parsons Hardness: 20 // Pretest // Calculate the interest on a loan # 2011 Sequence.Parsons > "It reads the amount of loan and interest rate, calculates the interest and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter principal"; >> ; /* Read */ << "Enter interest rate"; >> ; /* Calculate as product of and */ = * ; /* Print */ << ; }} > Type: parsons Hardness: 20 // Posttest // Input hourly rate, number of hours, compute total pay # 2012 Sequence.Parsons > "It reads the hourly rate and number of hours, calculates the total pay and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter hourly rate"; >> ; /* Read */ << "Enter number of hours"; >> ; /* Calculate as product of and */ = * ; /* Print */ << ; }} > Type: parsons Hardness: 20 // Calculation of hypotenuse // ---------------------------Division------------------------------------------- // Calculate the shares bought # 2015 Sequence.Parsons > "It reads the amount invested and cost per share, calculates the number of shares bought and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter investment"; >> ; /* Read */ << "Enter price per share"; >> ; /* Calculate by dividing by */ = / ; /* Print */ << ; }} > Type: parsons Hardness: 20 // Calculate velocity as distance divided by time # 2016 Sequence.Parsons > "It reads the distance covered and time spent, calculates the speed and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the distance covered"; >> ; /* Read */ << "Enter the time taken"; >> ; /* Calculate by dividing by */ = / ; /* Print */ << ; }} > Type: parsons Hardness: 20 // Cmputes bmi and prints healthy if bmi less than 25, and not healthy otherwise // mass in pounds, height in inches, bmi = (mass/height) * 703 // 2050 // Sequence.Parsons.Hidden // Input-ComputeHidden-Compute-Output // e.g., mean, stdev // But, No if-else or any other control // ---------------------------Demo Problem------------------------------------------- // Problem to help students practice with the user interface # 2999 Demonstration > "It prints Alpha, Bravo and Charlie." {(){ /* Prints A */ << "Alpha"; /* Prints B */ << "Bravo"; /* Prints C */ << "Charlie"; }} > Type: parsons Hardness: 20