Home Topic 4 Last Next

Topic 4—Computational thinking, problem-solving and programming (45 hours)

4.1 General principles (10 hours)

--- Thinking procedurally ---


Identify the procedure appropriate to solving a problem.


Teaching Note:

This includes identifying the steps and putting them in the correct order. Such as recipes, block-arrow-block-arrow.

LINK Connecting computational thinking and program design, introduction to programming.


Sample Question:


JSR Notes:


Just about everything we do in our lives is multi-step, and the order in which we do these steps almost always helps determine how well that procedure goes. So the planning of the order in which we will do things in a program is not unique to programming.

A classic thought exercise of a procedure you do every day is getting ready for school. There are a set number of things that have to be accompished, including getting washed up, eating breakfast, and organizing the things you will need to take with you to school. You could break down this entire process to a dozen or more smaller steps, like brushing your teeth, or putting your books into your bookbag. And there are varying orders of doing things that will still have you able to get ready. But one way or the other, there is a step-by-step procedure.

So too in coding. The computer (usually) does only one thing at a time, one step after another. So we come up with a procedure of steps we want it to follow when we write a computer program. It makes sense to think well about the best way for the procedure to proceed.


Non-Programming Examples

Identify the procedure appropriate to solving the following problem:

Example 1: Bake a cake - First, put all of the boxed ingredients into a bowl. Then add two eggs, and a cup of sugar. Mix. Put in the oven, and bake at 450 degrees for one hour. Remove and let cool. Then put the pre-made frosting on.

Example 2: Go to the store by car - Unlock the car, get in it, start it, drive to the store, park the card, turn off the car, get out, and lock it.

Example 3: Get ready to go to play hockey - Go to the dressing room, use the bathroom, fill up your water bottle, put on equipment, starting with the inner parts, and work outward and upward. Tape your socks. Gather your stick and water bottle and cloth for cleaning your visor, and head toward the ice.

Example 4: Do your shopping at 7-11 - Go to the store, look for things you need and put them in your shopping cart. When you have all of your items, go to the checkout.


Programming Example

Identify the procedure appropriate for solving the following problem:

Input grades for all school subjects, and calculate the average of the HL subjects, and the average of the SL subjects. Output those averages and which of the two is greater.


Java Code

15 public class ProjectForTopic4ProgrammingExamples {
17     public static void main(String[] args) throws Exception {
19         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
20         System.out.println("How many HL courses are you taking?");
21         int numHLCourses = Integer.parseInt(br.readLine());
22         System.out.println("How many SL courses are you taking?");
23         int numSLCourses = Integer.parseInt(br.readLine());
24         double totalSLScore = 0.0;
25         for(int i = 0; i < numSLCourses; i++){
26             System.out.println("What is the score of your next  SL course?");
27             double nextScore = Double.parseDouble(br.readLine());
28             totalSLScore += nextScore;
29         }
30         double avgSLScore = totalSLScore/numSLCourses;
32         double totalHLScore = 0.0;
33         for(int i = 0; i < numHLCourses; i++){
34             System.out.println("What is the score of your next HL course?");
35             double nextScore = Double.parseDouble(br.readLine());
36             totalHLScore += nextScore;
37         }
38         double avgHLScore = totalHLScore/numHLCourses;
40         System.out.println("Your average HL score is " + avgHLScore);
41         System.out.println("And your average SL score is " + avgSLScore);
42         if(avgHLScore > avgSLScore){
43             System.out.println("Which means you scored on average better for HL.");
44         }
45         else if(avgSLScore > avgHLScore){
46             System.out.println("Which means you scored on average better for SL.");
47         }
48         else{
49             System.out.println("You scored equally well on HL and SL courses.");
50         }
51     }  
52 }