Logout

Home Topic 4 Last Next

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

 

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

 

Situation Example 3: Fight - World of Warcraft

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: