Presentation is loading. Please wait.

Presentation is loading. Please wait.

Conditionals Exploring Computer Science Lesson 4-9.

Similar presentations


Presentation on theme: "Conditionals Exploring Computer Science Lesson 4-9."— Presentation transcript:

1 Conditionals Exploring Computer Science Lesson 4-9

2 Objectives The students will be able to:
Explain the concept of conditionals. Enhance a variable program with conditionals.

3 Write down the questions.
Journal What comes to mind when you hear the word “if”? What are some ways we use the word “if” in English? Write down the questions. Answer with complete thoughts and sentences or you will not receive full credit on your journal

4 If Statements in Computing
If you have started to think about building animations like simulations and video games then to build those more advanced programs, you will need to write code that involves decisions If (some condition) then do this

5 Examples When you exit Microsoft Word, it asks you if you want to save your file. If you click “Yes” the file is saved If you click “No” your changes are discarded In a car-race simulation, the driver steers the car around curves and past mile-markers. If the car stays on the road, the score increases. If the car goes off the road into the stands, the car crashes. If the driver gets the car over the finish-line, the time is posted and the driver wins!

6 Scratch “if” Block The Scratch “if” block looks like this:
Note that only a hexagon shaped block will fit

7 Example What does this program do?

8 Expand the Program Currently, it only does the first condition. Your task is to finish the program so that the cat will tell you the rest: If you are older than 2 "you don't need diapers" If you are older than 15 "you can drive" If you are older than 16 "you can see an R rated movie" If you are older than 17 "you can vote" If you are older than 20 "you can gamble" If you are older than 24 "you can rent a car" If you are older than 49 "you can retire“ Finally add: If the age is less than 3 "Sorry, you are not old enough for anything yet"

9 Remember Our Nutrition Program??
Add a nutrition guru to the program… The guru should give a positive message about being nutritious if the number of points becomes greater than 9. The guru should give a message about eating healthier food if the number of points becomes less than 4. Use broadcast to tell the guru what to say!


Download ppt "Conditionals Exploring Computer Science Lesson 4-9."

Similar presentations


Ads by Google