Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms For use in Unit 2 Exam.

Similar presentations


Presentation on theme: "Algorithms For use in Unit 2 Exam."— Presentation transcript:

1 Algorithms For use in Unit 2 Exam

2 Algorithms – recap Declare variables that you intend to use Declare numberOfSprints = 0 Declare sprintTime = 0 Declare fastestTime = 100 Declare slowestTime = 0 Declare totalTime = 0 Declare average as real = 0

3 Algorithms – recap Output and input – to display information and input data. Output “Welcome to the 100m sprint training program” Output “Enter the number of sprints completed” Input numberOfSprints

4 Algorithms – recap If statement. The section below updates the fastestTime variable if the sprint time is a lower value. if sprintTime < fastestTime then fastestTime = sprintTime endif

5 Algorithms – recap If statement. Enter an if statement in the space below to update the slowestTime variable if the sprint time is a greater value.

6 Algorithms – recap Loops – Repeat Until. Or For i = 1 to 10 For i = 1 to numberOfSprints Output “Enter sprint time” Input sprintTime **additional code could be placed here ** Next for

7 Algorithms – recap Loops – Repeat Until. Or For i = 1 to 10 Repeat Output “Enter sprint time” Input sprintTime **additional code could be placed here ** Until NumberofSprints

8 Algorithms – recap Loop In the space below write a loop that asks the user the age of 5 pupils and outputs whether they may learn to drive a car (over the age of 16).

9 Calculations Calculations are very similar if not identical in an algorithm when compared to code in a high level language such as Python. e.g. totalTime = totalTime + sprintTime

10 Task 1 Write an algorithm to perform the following:
Have a heading that states Bish Maths Test Enter 6 marks for a maths test. Use a loop For each mark state whether a Pass can be awarded (mark must be greater than 5). Assume mark is out of 10. Calculate and output the highest, lowest and average marks. #hint – you need to calculate highest, lowest and total within the loop as demonstrated on previous slides.

11 Task 1 - Solution

12 2016 Exam

13 Answer

14 Answer

15 Arrays (Lists) Lists can store multiple values, they are also known as arrays.
Declare goalsScored array (1..99) of integer Declare matchgoal = 0 For i = 1 to 11 Output “Enter goals scored for player”, i Input matchgoal goalsScored[i] = goalsScored[i] + matchgoal Output “Your goals for the season are “, goalsScored[i] Next i

16 Task 2 Write an algorithm to perform the following:
Have a heading that states Bish Computing Test Enter marks for four pupils who have completed three tests. Store their totals in an array. Calculate and output the average mark for each pupil.

17 Task 2 Solution

18 2015 Exam

19 Answer

20 Answer


Download ppt "Algorithms For use in Unit 2 Exam."

Similar presentations


Ads by Google