Logout

4.1.8

Deduce logical rules for real-world situations.

Teaching Note:

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

Sample Question:

sdfsdfsf

JSR Notes:

Situation Example 1: What time to set your alarm clock for

• Rules for determining what time to set your alarm clock:
• If it's a school day
• If you will be walking to school, set it for 6:00 a.m.
• But if you will be driven to school, you can set it for 6:15 a.m.
• If it's not a school day, then don't even set your alarm.

Situation Example 2: DDoS (Distributed Denial of Services Attack)

• Rules for determining whether it is a DDoS would be:
• If traffic that is unknown > 20% && traffic volume > 5 times the average
• OR traffic that is unknown && drop requests are both > 5%

Situation Example 3: Fight - World of Warcraft

• Rule that would indicate a fight to occur:
• If hit test between 2 characters && health > 100

This all leads to concepts of flow of control.

### Programming Example

```
14 public class AlarmSetting {
15     public static void main(String[] args) {
16
17         Scanner snr = new Scanner(System.in);
18         System.out.println("Is it a school day? true/false");
19         boolean itsASchoolDay = snr.nextBoolean();
20         if(itsASchoolDay){ //CONDITION for A or B
21             System.out.println("Will you be walking to school, instead of driving, today?"); //DECISION A.
22             boolean walkingToSchool = snr.nextBoolean();
23             if(walkingToSchool){ //CONDITION for a. or b.
24                 System.out.println("Set your alarm for 6:00 a.m."); //DECISION a.
25             }
26             else{
27                 System.out.println("You can set your alarm for 6:15 a.m."); //DECISON b.
28             }
29         }
30         else{
31             System.out.println("There is no need to set you alarm!!!"); //DECISION B.
32         }
33     }
34
35 }
36
```

After extra coding notes blended in:

After extra coding notes blended in: