Logout

Home Topic 4 Last Next

--- Thinking logically ---

4.1.4

Identify when decision-making is required in a specified situation.

 

Teaching Note:

Links to procedural thinking—alternative procedures.

TOK Reasoning as a form of decision-making.

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


 

Sample Question:

sdfsdfsf

 

JSR Notes:

Introduction

You'll often hear me say that there are two things that computers are good at, anything repetitive, and anything requiring complex decision making. It is the later that this is about.

We, as humans are also pretty good at complex decision making; we just can't do that kind of processing as quickly or for as complex systems, as computers potentially can. Just think of the hundreds of decisions a teacher makes teaching a class every day. Should I teach this? Or should I teach that? Should I continue teaching this subject? One more example or not? Should I respond to that student's inattention? Is the lighting good enough, and the temperature just right? Do I have time to help this student? etc. etc. etc. Or you playing a team sport. Practically every few seconds you are making a decision.

For computers, a good example to think of is how a game plays . There are millions and millions of possible ways it can play out; no two games are ever the same, and this is all because of the different decisions made from one second to the next, with each decision potentially influencing the next decision. As you would expect, the code of games is full of conditions which result in decisions.

 

Identifying When Decision-making Is Required

We will want to make a decision whenever the state of our program is such that proceeding one way or the other is possible, and we have to decide which is better/appropriate. We can do this, or we can do that; or indeed we should do this, or we should do that. Doing so pretty well always boils down to a situation if such-and-such, do such-and-such, or else if such-and-such, do such-and-such.

 

Structure of Decision Making Situations

It is useful to jump right to Java's decision making structures/terms. Java decision making uses if, if/else, if/else if etc. blocks

if

When a condition evaluating to true should result in a decision being made, and otherwise we should do nothing, we use: if

if/else

When there is a condition that can evaluate to true or to false, and different things are done depending on which it is, we use: if / else

if/else if/else

Sometimes it is more than just a single true - false situation, so when multiple decisions/procedure are to be chosen from, we use: if, else if, else

 

Potential Question

And back to the assessment statement, a question could be worded like this: "Identify situations when decision making is needed in the process of baking a cake.": And the answer could be something like this:

 

Programming Example

 
14 public class DecisionsSituations {
15     static Scanner snr;
16     public static void main(String[] args) {
17         Scanner snr = new Scanner(System.in);
18         simpleIf();
19         ifElse();
20         multipleIfElseIf();
21     }
22     
23     public static void simpleIf(){
24         System.out.println("Is there any possibility of a nut reaction? true/false");
25         boolean nutReactionPossible = snr.nextBoolean();
26         if(!nutReactionPossible){ //ONE IF ONLY
27             System.out.println("You can add nuts.");
28         }
29         System.out.println("Continue adding ingredients.");
30     }
31     
32     public static void ifElse(){
33         System.out.println("Is it raining? true/false");
34         boolean isRaining = snr.nextBoolean();
35         if(isRaining){ //IF - ELSE
36             rainyDrivingMethod();
37         }
38         else{
39             dryDrivingMethod();
40         }
41     }
42     
43     public static void multipleIfElseIf(){
44         System.out.println("What is the temperature outside?");
45         double outsideTemperature = snr.nextDouble();
46         if(outsideTemperature < 0){ //MULTIPLE IF - ELSE IF
47             System.out.println("Put on a winter jacket");
48         }
49         else if(outsideTemperature < 15){
50             System.out.println("Put on a sweater.");
51         }
52         else if(outsideTemperature < 25){
53             System.out.println("Put on a long-sleeve shirt");
54         }
55         else{
56             System.out.println("You can just wear a short-sleeve shirt");
57         }
58     }
59     
60     public static void rainyDrivingMethod(){}
61     
62     public static void dryDrivingMethod(){}
63     
64 }
65