caribbean secondary education certificate (csec) information technology syllabus teacher orientation...

70
CARIBBEAN EXAMINATIONS COUNCIL CARIBBEAN SECONDARY EDUCATION CERTIFICATE (CSEC) INFORMATION TECHNOLOGY SYLLABUS TEACHER ORIENTATION WORKSHOP AUGUST 11 TH – 15 TH , 2008 TRINIDAD & TOBAGO Facilitator: Gerard Phillip

Upload: alexis-porter

Post on 14-Jan-2016

222 views

Category:

Documents


2 download

TRANSCRIPT

Slide 1

CARIBBEAN EXAMINATIONS COUNCIL

CARIBBEAN SECONDARY EDUCATION CERTIFICATE (CSEC)INFORMATION TECHNOLOGY SYLLABUSTEACHER ORIENTATION WORKSHOPAUGUST 11TH 15TH, 2008TRINIDAD & TOBAGO

Facilitator: Gerard Phillip 1PROBLEMSOLVING

CSEC INFORMATION TECHNOLOGY2INTRODUCTIONHow are instructions given to the computer?Computer programs finite set of precise instructions written in a computer languageBefore program is written we must find a way to solve the problemAfter figuring out how to solve the problem we then translate the solution into a language meaningful to the computer3INTRODUCTIONGiving precise, unambiguous instructions is not inherent in human natureConsider the following: Proceed a mile or so down the road until you reach the roundabout. Turn left at the roundabout and follow the road until you reach a green house on the right hand side. The Post office is about the 3rd or 4th building on the right after the green house. You cant miss it!4INTRODUCTIONProblem-solving statements/ instructions should be:PreciseUnambiguousMust be in a logical sequenceFinite, i.e. terminate after a definite number of steps

Teachers must ensure that students have a good grasp of what these attributes meanStudents should engage students in problem-solving exercises involving everyday problems they can relate to.5PROBLEM-SOLVING ON THE COMPUTERExamples of everyday problems:

Write a recipe for making a cheese sandwichWrite instructions to teach your mom how to retrieve voice message from a generic cell phoneWrite instructions to give directions to a visitor to get to the nearest hospital, starting from the school premisesWrite instructions to tell a novice how to download music from the Internet.6PROBLEM-SOLVING ON THE COMPUTERThe design of any computer program involves two phases:The Problem-solving PhaseThe Implementation Phase

Problem-Solving Phase comprises the following steps:Define the problemFind solutions to the problemEvaluate alternative solutionsRepresent the most efficient solution as an algorithmTest the algorithm for correctness7 DEFINING THE PROBLEMThe problem must first be defined: Ensure that students understand the Problem Defining the problem is the first step towards finding a solutionIt helps the programmer to understand what is given and what is required If the programmer does not fully understand what is required, he/she cannot produce the desired solution to the problem8DEFINING THE PROBLEMOne of the biggest challenges faced in problem-solving is understanding the problem to be solved.Defining the program can be accomplished by decomposing the problem into three key components:What is given (the inputs)The tasks that must be performed (processing)The expected results (the output)9THE DEFINING DIAGRAMDefine the problem by constructing a defining diagram A table with three columns which represents the three components: input, processing and output.E.g. A program is required to read three numbers and calculate and print the total.

INPUTPROCESSINGOUTPUT3 numberse.g. Num1, num2, num3Get 3 numbersAd numbers togetherPrint totalTotal10THE DEFINING DIAGRAMInput refers to the source data provided - easily identified by the keywords given, read or accept, inputOutput refers to the end result required - keywords are print, display, produce, outputProcessing are the actions must be performed to achieve the required output - it answers the question: What must I do with the inputs in order to produce the desired result?11THE DEFINING DIAGRAMIn the defining diagram, the actions must be listed in a logical sequential mannerAll necessary actions must be explicitly statedThe processing section is NOT the solution to the problem. Its simply the actions that must be done in order to solve the problemNote that in some cases the input, processing and output statements might not be as explicitly stated.12PROBLEM 2E.g. of problem not clearly stated to facilitate student identification of the problem: Given three integers representing the age of three boys respectively, write a solution to find their average age and also determine the age of the oldest boy.

This problem statement could have been stated more precisely to read: Given three integers A, B, C, representing the age of three boys respectively, write a solution to find and display their average age as well as the age of the eldest boy.13DEFINING DIAGRAMTwo major tasks to be performed, each consisting of multiple actions:

INPUTPROCESSINGOUTPUT3 integersSay age1, age2, age3Read/accept/get 3 integersFind the average of the three integersFind the highest agePrint the average, highest ageAverage-ageHighest-age14PROBLEM 3The cost of a new car is the sum of the wholesale cost, the local sales tax and the dealers percentage mark-up. Assuming that the dealers mark-up is 10 percent of the wholesale cost and the sales tax is 6 percent, design an algorithm to read a car ID (an integer value) and the wholesale cost of the car (a real value) and print the car ID and the cost to the consumer.15PROBLEM 3Here, input and output data are clearly stated. To determine the processing steps we may ask What should I do with wholesale cost in order to find the cost to the consumer?

INPUTPROCESSINGOUTPUTCar-ID, Wholesale-costRead/get wholesale-costCalculate dealers mark-upCalculate the sales taxFind the sum of the wholesale-cost, the dealers mark-up and the sales taxPrint the resultsCar-IDConsumer-Cost16THE PROBLEM WITH PROBLEM SPECIFICATIONMany real-world programming problems are not always preciseInitial descriptions are often vague, and ambiguousStudents should be encouraged to evaluate problem statements and ask questions if they are perceived as ambiguousAlso, some information may be implicit in the problem statement and therefore should be taken into account when defining the problem17THE PROBLEM WITH PROBLEM SPECIFICATIONHave students evaluate several problem statements, ranging from simple to complex, some precise, some ambiguous, lacking pertinent information.Here are some examples of imprecise problem statements:#4: Write a program to print a list of all the employees who have been in the company for over five years#5: Write a program that reads a file that contains information on the height, weight and age of 100 children. The program should print the names of all the children who are overweight.18FINDING A SOLUTION TO THE PROBLEMIntroductionThe Concept of VariablesChoosing Variable NamesInitialization of Variables

19FINDING A SOLUTION TO THE PROBLEMINTRODUCTIONNow that we have defined the problem, we know what we need to do. We must now figure out how to do it.A problem can have many different solutionsLet students arrive at one that works, however long-windedOnce a solution is found, it can then be reviewed to see how it can be optimized, or made more efficientThe first approach in deriving a solution to a problem is to do the problem by hand, noting each step as you proceed.20FINDING A SOLUTION TO THE PROBLEMINTRODUCTIONProblem #6: Find and print the average of three numbersDefine the problem

Create sample data: sample input data 5, 3, 25Execute each processing step in the defining diagram manually

INPUTPROCESSINGOUTPUT3 NumbersSay num1, num2, num3

Read/get 3 numbersFind the averagePrint averageaverage21FINDING A SOLUTION TO THE PROBLEMINTRODUCTIONHaving completed a manual solution to the problem, the next step is to write your solution as a sequence of instructionsInitial solutionGet the first number, call it num1Get the second number, call it num2Get the third number, call it num3Add num1 + num2 + num3Divide result by 3Print resultStop22FINDING A SOLUTION TO THE PROBLEMTHE CONCEPT OF VARIABLESIn our solution to problem #6, we did not tell the computer where to put the result of the add operation. The result must be stored somewhere so it can be accessed later.

Grandmas fluffy pancakes: Method:Sift flour in mixing bowl ...Melt the butter in a frying pan ...Pour batter into a bowl ...

Just as we need containers to hold or store ingredients, likewise, in computation, we need something to store or hold the values we manipulate23FINDING A SOLUTION TO THE PROBLEMTHE CONCEPT OF VARIABLESIn the computer, values are stored in memory locations.There are many memory locations, so in order to keep track of where our values are stored we need to place a label or identifier on a particular memory location.The label or identifier is called a variable.A variable is a symbolic name assigned to a memory location that stores a particular value24FINDING A SOLUTION TO THE PROBLEMTHE CONCEPT OF VARIABLESWhen we say num1, num2, etc we are actually defining a variable or an identifier for each number, so that we can refer to (access) it later.We need to tell the computer where to put the result of the addition of num1, num2, num3Add num1 + num2 + num3 storing in SumThis would tell the computer that the result of the computation should be stored in a memory location called Sum.25FINDING A SOLUTION TO THE PROBLEMTHE CONCEPT OF VARIABLESLikewise, we must address a similar issue in the last two statements where we stated,Divide result by 3Print result

Computations are performed by the ALU, part of the CPU and results are temporarily stored in registers within the cpuThese values must be stored in memory locations if they are to be accessed later

26THE CONCEPT OF VARIABLESThe word variable is derived from the verb to vary. This means that the value stored in a particular location can change from time to time, although the label remains the same.When new values are placed into previously assigned memory locations, the old values are replaced by the new .

27FINDING A SOLUTION TO THE PROBLEMTHE CONCEPT OF VARIABLESIt is always useful to illustrate the concept of a variable by using diagrams to show the memory locations:

Memory locations5325Num 1Num 2Num 3Variables28FINDING A SOLUTION TO THE PROBLEMTHE CONCEPT OF VARIABLESWe can now revise the initial solution to include the new variables called sum and average

Get three numbers, say num1, num2, num3Add num1, num2, num3, storing in sumDivide sum by 3, storing in averagePrint average

29

THE CONCEPT OF VARIABLESCHOOSING VARIABLE NAMESIts good practice to choose variable names that reflect the kind of data that is being storedIt helps the programmer as well as the reader to understand the solution better Its important that students grasp the concept of variables very early in the problem-solving phase.

30EVALUATE ALTERNATIVE SOLUTIONSHaving found a solution to a problem the programmer should proceed to explore alternative solutionsThe aim is to arrive at the most efficient solutionThe initial solution is usually the first that comes to mind, but is not always the best solutionThe programmer must evaluate all feasible alternatives and choose the optimal solution31EVALUATE ALTERNATIVE SOLUTIONSPoints to consider when developing alternative solutions.Can the result be derived differently?Can the solution be made more general? Would it work if there were 100 integers, instead of 3?Can the solution be used for another problem? E.g. Average temperature or average grade?Can the number of steps be reduced and still maintain the logic? Can it be made more robust? What would happen if incorrect data is entered?32REDUCING THE NUMBER OF STATEMENTSWe can reduce the number of statements by combining two arithmetic statements into one:Add num1, num2, num3 can be written asSum = num1 + num2 + num3(the variable sum is assigned the value of num1 plus num2 plus num3)Divide sum by 3 storing in average can be writtenAverage = sum/3We can combine the two statements to produce:Average = sum/333REVISED SOLUTIONOption 1Get num1, num2, num3Sum = num1 + num2 + num3Average = sum/3Print AverageStopOption 2Get num1, num2, num3Average = (num1 + num2 num3)/3Print AverageStopThe most efficient solution should have the following attributes:Should be maintainableShould be memory efficientShould be robust34INITIALIZATION OF VARIABLESVariables that are used as counters or used to store totals should always be assigned an initial value of 0 before they are incremented.This is called initializationE.g. Count = 0This ensures that the variable is cleared of any values that may have been assigned in a previous execution of the program.Initialization may appear to be a trivial step, but it is very important. Many programs fail to work correctly, simply because the programmer forgot to initialize a counting variable.35WHAT IS AN ALGORITHM?At this time, we can now introduce the term algorithm. An algorithm is a sequence of precise instructions for solving a problem in a finite number of steps.Properties:Algorithms must: be precise, be unambiguous, be logically sequenced, give the correct solution an all cases, and eventually end.36WHAT IS AN ALGORITHM?Algorithmic structure

Header: Algorithms name or titleDeclaration: Brief description of algorithm and variables used. i.e. A statement of purpose as well as the initialization of variablesBody: Sequence of stepsTerminator: An end statement37 ALGORITHMIC STRUCTUREProblem:Write an algorithm that prompts a student to enter his/her name and age, accepts the name and age and then display a welcoming message on the screen such as hello Michael! You are 16 years old!

Write the algorithm identifying the header, declaration, body and terminator.38ALGORITHMIC STRUCTUREAlgorithm Student data {Header}This algorithm displays a students name and age on the screen. {declaration}StartDisplay Enter your name:Accept NameDisplay Enter your age:Accept AgeDisplay Hello, NameDisplay You are, Age, years oldStop{Terminator}

{Body}39FLOWCHARTS VERSUS PSEUDOCODEPseudocode is more concise, closely resembles programming languageFlowchart gives good view of the structure and flow of the logicBeginners tend to follow the logic easier when using flowcharts rather than pseudocodeLonger, more complex solutions are better represented using pseudocode.40FLOWCHARTS VERSUS PSEUDOCODEUsage is a matter of preference for experienced programmersStudents should be asked to use both flowcharts as well as pseudocode to represent algorithmsFlowcharts must use special geometrical objects that designate the basic steps of a program:

Input/OutputProcessing/ AssignmentDecisionStart/ Stop41PSEUDOCODE AND FLOWCHARTStartGet num1, num2, num3Average (num1 + num2 + num3)/3Print AverageStop

StartRead num1, num2, num3Average (num1+num2+num3)/3Print AverageStop42SELECTION STRUCTURESSelection (decision)The IFTHEN selection statement

Syntax:IF (expression) THEN{Statement (s)}Execute this statement if logical expression is TRUEThis construct is used when no action needs to be performed if the expression returns false. 43SELECTION STRUCTURESGet MarkIF Mark >= 50 THENPrint Well doneStop

This requires only that the expression Well done be printed should the student score 50 marks or more.No action is intended should the mark be less than 50

44SELECTION STRUCTURESIF THEN ELSE construct syntax:IF (expression) THEN{Statements}executed only if condition is TRUEELSE{Statements}executed only if condition is FALSE ENDIFOnly one group of statements could be executed each time the program is executed.45SELECTION STRUCTURESGet MarkIF Mark >= 50 THEN PRINT Well doneELSE PRINT Must do betterENDIFStop

Well done will be printed should the students mark be 50 or greater.If the mark is less than 50 then the statement Must do better would be printed. 46SELECTION STRUCTURESA worker in a clothing factory is paid an additional incentive according to the amount of shirts she folds. The basic salary is $300.00 per week. Should the worker fold 500 or more shirts per week, an additional 15%, is added to her basic salary. If the worker folds less than 500 shirts however, she is paid just the basic salary. Write an algorithm to determine and print the salary of the worker.

47SELECTION STRUCTURESWrite an algorithm to accept any two numbers, the first a numerator and the second the denominator. If the second is equal to zero print Cannot divide by 0. Otherwise divide the first number by the second and print the answer.

48SELECTION STRUCTURESA teacher has realized an error in his marking of students scripts. He has therefore decided to credit all students who got 55 marks and under with an additional 10 marks. Those who got more than 55 would be credited with an additional 15 marks. Write an algorithm to accept the mark from a student in a class. Calculate and print the students adjusted mark.

49SELECTION STRUCTURESA store offers customers a discount of 15% if the cost of any item purchased is equal to or exceeds $200.00. Should the cost be less than $200.00 however, then a 5% discount is applied. Write an algorithm to accept the cost of an item. Apply the relevant discount and calculate and print the net cost (cost discount).50REPETITION STRUCTURESRepetition or Loop or Iteration structures allow statements to be repeated a fixed number of times or until some condition evaluates to false.There are three repetition constructs:FOR Loop- counted loopREPEAT Loop- conditional loopWHILE Loop- conditional loop51REPETITION STRUCTURESThe FOR loop construct syntax:FOR = TO DO{Statements} ENDFOR

e.g. FOR X = 1 to 10 DO {Statements to be executed} ENDFOR

52REPETITION STRUCTURESThe FOR loop is used when the required number of iterations (loops) is known beforehandThe statements are repeated as long as the value of the identifier specified by the element does not exceed the value specified by . A comparison is made each time the loop iterates to check whether the is exceeded. If it is not then the counter value is incremented by one (the default step value) 53REPETITION STRUCTURESThe 12 workers employed in the folding section of a clothing factory are each paid a basic salary of $500.00 per week. An incentive is offered according to the amount of shirts folded. Should a worker fold 600 or more shirts per week a bonus of 20%, is added to his/her basic salary. If a worker does not fold as much as 600 shirts however, he/she is paid just the basic salary. Write an algorithm to determine and print the salary of each worker.

54REPETITION STRUCTURESA teacher has realized an error in his marking after having marked all his students scripts. He has therefore decided to credit all students who got less than 60 with an additional 5 marks. Those who got 60 and over would be credited with an additional 15 marks. Write an algorithm to accept the initial marks obtained by the 20 students in the class. Calculate and print each students adjusted mark. The teacher would like to determine the class average after the marks are credited. Should the class average exceed 60, Instructions well received should be printed. Otherwise, Reconsider Teaching Methods should be printed.

55REPETITION STRUCTURESA store offers customers a discount of 15% if the total cost of items purchased is equals or exceeds $400.00. Should the total be less than $400.00 then 5% discount is given. Write an algorithm to accept the costs of five items. Calculate and print the total cost. Apply the relevant discount and calculate and print the net cost (total cost discount).56REPETITION STRUCTURESWHILE LoopThe WHILE Loop construct syntax:INPUT ValueWHILE (expression) Do{statements} executed if Boolean argument in logical expression is trueINPUT value to be testedENDWHILE

57REPETITION STRUCTURESWHILE LoopIn processing, the argument (condition) between WHILE and DO is tested to see if it is true. If the condition returns true, the statement(s) that follow DO will be executed. If the condition returns false, execution of the WHILE statement is stopped. It is possible for the loop never to be executed if the initial input renders the condition is to be proven false.

58REPETITION STRUCTURESWHILE LoopThe while loop can iterate indefinitely, as long as the condition in the argument expression remains true. It is terminated only when the condition returns false.

Write an algorithm that reads a number of arbitrary integers and find the average of all numbers read. The program should be terminated if the sentinel value 999 is entered.59REPETITION STRUCTURESWHILE LoopWrite an algorithm to accept an unspecified amount of integers. Calculate and print the sum of the numbers entered. The algorithm should also determine and print the highest number entered. The process should be terminated if the number entered exceeds 1000.

Write an algorithm to accept the price of items purchased at a supermarket. The entry of prices should continue as long as the price entered is not $101.00. Calculate and print the total cost of items purchased.60REPETITION STRUCTURESREPEAT LoopRepeat Loop construct syntax:REPEAT{statements to be executed}UNTIL (Boolean expression)

The repeat loop is used to iterate a sequence of events until a specific condition becomes true. The statements in the body of a Repeat loop are executed at least once, because the test of the condition takes place at the end of the loop. 61TRACE TABLESState what is printed when the following algorithm is executed.FOR X = 1 to 3 DO FOR Y = 1 to 3 DO Product = Y * X Print Product ENDFORENDFOR

62TRACE TABLESWhats printed by the following Algorithm?AMOUNT = 2G = 4WHILE AMOUNT < 50 DoG = G*2AMOUNT = AMOUNT + GPrint AMOUNT, GENDWHILE

63TRACE TABLESINPUT A,B,CA = B + CB = A CC = A + BIF A > B THENC = A BELSEC = B AENDIFPrint A,B,CState what is printed by the algorithm above when the following data is input:(i)5, 7, 9(ii) 9, -7, 564TRACE TABLESComplete the trace table based on the following algorithm.B = 2C = 4Total = 3WHILE B