0% found this document useful (0 votes)
23 views5 pages

Unit 4 Lesson 03 Loops and Strings Lesson Plan

Uploaded by

shuguang liao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

Unit 4 Lesson 03 Loops and Strings Lesson Plan

Uploaded by

shuguang liao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lesson P lan

Lesson 4.3: Loops and Strings

Overview
This lesson will combine two concepts: String variable and loops. Students will
use while and for loops to traverse and manipulate String objects.

Student Learning Objectives


ENDURING UNDERSTANDING

CON -2
Programmers incorporate iteration and selection into code as a way of providing
instructions for the computer to process each of the many possible input values.

LEARNING OBJECTIVE ESSENTIAL KNOWLEDGE

CON -2.F: For algorithms in the context of ➢ CON-2.F.1: There are standard
a particular specification that involves algorithms that utilize String
String objects: traversals to:
● Identify standard algorithms. ● Find if one or more substrings has
● Modify standard algorithms. a particular property
● Develop an algorithm. ● Determine the number of
substrings that meet specific
criteria
● Create a new string with the
characters reversed

M at er ials an d R esou r ces

● Presentation system (LCD projector/Interactive whiteboard)


● 4.3 Loops and Strings in the CSAwesome e-book

1
Lesson P lan
Lesson 4.3 : Loop s an d St r in gs

● Kahoot - Review Strings


● Processing Strings with Java Loops (YouTube Video, optional)
● Unit 4.3 Worksheet (Solution)
● POGIL Activity Unit 4 Lesson 3
● Unit 4 Lesson 3 Exit Ticket (Solution)
● CS Awesome! Programming Solutions

Lear n in g Act ivit ies

Estimated Length: 90 mins

Day 1

● Hook/Motivation (10 mins):


○ This Kahoot activity will review String methods length(), indexOf() and
substring().
● Experiences and Explorations (30 mins):
○ Direct Instruction :
■ After the Kahoot activity, go over the methods in the Runestone
site lesson length() , indexOf( ) and substring( ) and remind them
that strings start at index 0 showing Figure 1 in the lesson. Ask
them what substring command would return the word “is” and
“test”.
■ (Optional) Show the YouTube video Processing Strings with Java
Loops. Pause the video and check for understanding when:
● The for loop is created (0:57)
● substring is used to isolate one character (1:37)
● The if statement is created to count spaces (1:50)
● The addition of the troubleshooting print statement (3:27)
● The String out of range error (4:02)

2
Lesson P lan
Lesson 4.3 : Loop s an d St r in gs

○ POGIL / Collaborative Group work:


■ Pair students into groups of 2 to go through CodingExercise
ActiveCode1 using the Java visualizer. Because tracing a loop is a
cognitive technique that requires practice, tracing this loop
through a visualizer is ideal.
■ POGIL Activity Unit 4 Lesson 3 (Solutions)
■ Afterwards, students individually make the changes indicated in
the Coding Exercise.
○ Independent Practice : Check Your Understanding 4-3-1
○ Rethink, Reflect, and/or Revise (5 mins):

○ (Think-Pair-Share) Have students complete Exit Ticket 4.3 (Solution)


with their elbow partners. This is a loop tracing exercise similar to the
Magpie Lab.

Day 2:

● Hook/Motivation (5 mins):
○ Check for Understanding 4-3-2: students complete individually.
○ Discuss as a class what mistakes were made during attempts to complete.
● Experiences and Explorations (30 mins):
○ Direct Instruction: Go through 4.3.2. For Loops: Reverse String on
Runestone.
○ Guided Practice: Run Active Code in Activity 3 and guide students to
make the required changes.

○ Programming Challenge
■ Students should work in pairs to complete the Programming
Challenge on Runestone
○ Independent Practice
■ Students individually complete Unit 4.3 Worksheet (Solutions)
● Rethink, Reflect, and/or Revise (10 mins):
○ Go over Solutions to Unit 4.3 Worksheet

3
Lesson P lan
Lesson 4.3 : Loop s an d St r in gs

○ If students have not finished, go over at least 1 or 2 of the problems and


review the rest the next class period.
○ NOTE: This is a challenging worksheet. Some of these questions are AP
level questions or harder.

Ch eck for U n d er st an din g


● Interactive Exercises: Check for Understanding
● Coding Exercises: Activecode 1 and 2, Programming Challenge 4.3.1
● Common Misconceptions:
○ Students forget that length() returns the number of characters instead of
the last index and substring uses an index that begins at 0.
○ In a loop, accidentally comparing an index to equal the String’s length
index<=str.length() which will cause a run-time exception since the
last index is length-1 since strings begin at index 0.
○ Students get confused when the result of substring() is an empty String vs.
going out of bounds. Here are the rules:
■ The substring(index1, index2) method throws a
StringIndexOutOfBoundsException only if:
1) The starting index is negative
2) The ending index is larger than the length of the string
3) The starting index > ending index
● Personal Progress Check (College Board): The College Board AP
Classroom provides a quiz bank and Personal Progress Checks. You may
create a formative assessment quiz for topic 4.3 in the AP Classroom.
Review the results in class to identify and address any student
misunderstandings.

4
Lesson P lan
Lesson 4.3 : Loop s an d St r in gs

Differentiation: More Practice


From the Codingbat website, these two problems in Warmup-1 are nice
challenges:
● stringE
● everyNth
From the PracticeIt site:
● BJP3 Exercise 3.18: vertical
● BJP3 Exercise 3.19: printReverse

Differ en t iat ion : En r ich m en t

● This video from Udacity shows the contains() method and how it can be used
with a String traversal to find vowels in a String. The contains() method is not on
the AP test, but it is a handy method!

Back gr ou n d Kn owled ge

This Youtube video from Nick Parlante (Codingbat) explains how to use
substring in a Codingbat problem.

Manipulating Characters in a String from the Java Oracle Documentation.

T each in g T ip s
● CSP →CS A Tips
○ Students who took CSP should be familiar with the iteration process.
However, combining Strings and String methods with iteration is a new
concept. These concepts should be drilled both separately and together.

You might also like