UTPA STEM/CBI Courses/Computer Science/Repetition

Course Title: Computer Science I

Lecture Topic: Repetition structure

Instructor: Gustavo Dietrich

Institution: UTPA

Backwards Design edit

Course Objectives

  • Primary Objectives- By the next class period students will be able to:
    • Understand the advantage or necessity of using repetition structures to solve certain type of problems
    • Recognize the categories and subcategories of loops (counter-controlled vs. event-controlled; eof,sentinel,flag)
    • Understand the structure of loops (initialization of loop controller, testing of loop controller, updating of loop controller, body of the loop)
    • Understand how different repetition structures work (pre-test vs. post-test)
    • Write C++ code to implement the different repetition structures (while, for, do-while)
  • Sub Objectives- The objectives will require that students be able to:
    • Create logical and relational expressions
    • Identify syntax and logical errors in repetition statements (the semicolon after the loop’s heading, the use of curly braces to specify a block of statements, wrong placement of the statement updating the loop controller, etc.)
  • Difficulties- Students may have difficulty:
    • Understanding the underlying concepts involved in looping (use analogies)
    • Understanding when and how to use loops when given a problem (use analogies)
    • Creating complex conditional expressions
  • Real-World Contexts- There are many ways that students can use this material in the real-world, such as:
    • Any of those situations that require the repetition of actions to solve a problem. For example,
      • Mathematical field: calculation of sin x, Euler’s value e, greatest common divisor, etc.
      • Business field: calculation of an average, validation of a password/user name combination, etc.
      • Engineering field: calculation and displaying of the trajectory of a projectile, filling of a table with values read from a sensor, etc.


Model of Knowledge

  • Concept Map
    • Analysis of problem, requires
      • Critical thinking skills
      • Summarizing skills
    • Design of solution (algorithm design), requires
      • Problem decomposition skills
      • Understanding of underlying programming concepts
        • Data types
        • Sequence
        • Control structures
          • Selection
          • Repetition
        • Modular programming (functions)
        • Arrays
        • Abstract data types
          • Structures
          • Classes
        • Pointers
        • Data structures and algorithms
          • Trees
          • Searching
          • Sorting
      • Use of design tools -- pseudo code writing skills
    • Implementation of solution
      • Tools of the trade
        • Learned in Lectures through
          • Slides
          • Analogies
          • Sample programs
          • Group exercises
        • Using C++ to implement underlying concepts (listed above)
        • Applying underlying concepts, covered in lectures using
          • In-class exercises
          • Lab assignments
          • Homework assignments


  • Content Priorities
    • Enduring Understanding
      • Have analysis skills
      • Have design skills ( includes knowledge of pseudo code)
      • Know Control Structures
        • Sequence
        • Module
        • Selection
        • Repetition
      • Know C++ syntax rules
    • Important to Do and Know
      • Know how to use software development tools like MS VC++
      • Team work skills
    • Worth Being Familiar with
      • Time management

Assessment of Learning

  • Formative Assessment
    • In lectures:
      • Asking questions to the students and providing feedback after their reply (informs me and them)
      • Asking the students to discuss with their partner the answer to a question or a topic just covered (informs them)
      • Developing a program on the screen with the students’ collaboration (informs me and them)
    • In their own time:
      • Asking the students to use a software tool that presents them multiple choice questions and the corresponding feedback after their answer (informs them)
      • Asking the students to use the study guide provided a week before each test to self-evaluate their knowledge (an answer key is provided the day before the test) (informs them)
  • Summative Assessment
    • In labs/home:
      • Lab assignments for assessing their knowledge of the programming language syntax
      • Homework assignments for assessing their problem solving skills
      • Tests
        • MC T/F for assessing their knowledge of the concepts taught
        • Assessment questions in test to evaluate them individually

Legacy Cycle edit

OBJECTIVE

By the next class period, students will be able to:

  • Solve problems that require the use of loops

The objectives will require that students be able to:

  • Analyze the problem
  • Design the solution using pseudo code
  • Recognize the type of repetition structure required to solve the problem
  • Implement the algorithm using C++


THE CHALLENGE

Calculating the average temperature of the McAllen-Mission-Edinburg-Pharr metropolis would not be difficult since you would need to sum up only four temperatures. But how would you calculate the average temperature of the whole planet?

GENERATE IDEAS

  • Grab a calculator and imagine you have to determine the average temperature of the whole planet. List the steps that you would take to do this
  • Is this a repetitive task?
  • How many values do you process at a time? Can you process hundreds of them in just one step?
  • Do you know how many values you need to process in total?
  • Where would you expect to get the data from?
  • Would you do any validation?


MULTIPLE PERSPECTIVES

  • Discuss the problem with your partner
  • Look for possible solutions in the textbook
  • Search the web to find out what is done in the real world

RESEARCH & REVISE

  • Same as above

TEST YOUR METTLE

  • Discuss with your partner a possible solution for the problem
  • Create the algorithm and walk through it
  • Run my sample solution and check if the results are what you expected from your algorithm walk through

GO PUBLIC

  • Write a program that reads the temperatures from a file and determine the average (group evaluation)
  • Answer the assessment questions at the end of the test (individual evaluation)



Pre-Lesson Quiz edit

True/False

Indicate whether the statement is true or false. When you are finished making your selections, click the "Submit" button.

1 Loop control variables are automatically initialized in a loop.

TRUE
FALSE

2 Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5.

n = 1;
while (n < 5)
{
   n++;
   cout << n << " ";
}

TRUE
FALSE

3 The control variable in a flag-controlled while loop is a bool variable.

TRUE
FALSE

4 The do...while loop has an exit condition but no entry condition.

TRUE
FALSE


Test Your Mettle Quiz edit

Multiple Choice

Identify the choice that best completes the statement or answers the question. When you are finished making your selection, click the "Submit" button.

1 Loops are called post-test loops.

break
for
while
do...while

2 Consider the following code. (Assume that all variables are properly declared.)

cin >> ch;
while (cin)
{
   cout << ch;
   cin >> ch;
}

sentinel-controlled
flag-controlled
EOF-controlled
counter-controlled