# UTPA STEM/CBI Courses/Numerical Methods and Statistics/Loop and Case Structures

Course Title: Numerical Methods and Statistics
Lecture Topic: Loop and Case Structures
Instructor: Javier A. Kypuros, Ph.D.
Institution: University of Texas-Pan American

## Backwards Design

Course Objectives
* Primary Objectives- By the next class period students will be able to:
** understand and program basic loop and case structures and ;
** decompose problems into basic numerical algorithms.
* Sub Objectives- The objectives will require that students be able to:
** program "For" and "while" loops, and ;
** program "if-then-else" and switch statements.
* Difficulties- Students may have difficulty:
** understanding the logic of loop structures ;
** translating iterative processes into a "For" or "While" loop ;
** properly formulating condition statements.
* Real-World Contexts- There are many ways that students can use this material in the real-world. Here is an example:
Loops and case structures are used in nearly all numerical methods algorithms. Numerical methods are used to solve engineering problems that cannot be done so reasonably "by hand." Finite Element Analysis, Dynamic System Simulation, Controller Design, and Computation Fluid Dynamics are just a few examples of numerical engineering analyses.
Model of Knowledge
* Concept Map
** Loop Structures
** For vs. While loops
** Case structures
** Switches vs If-Then-Else Statements
* Content Priorities
** Enduring Understanding
*** Effective use if loop structures in iterative numerical processes
*** Effective use of case/condition structures in logic decisions
** Important to Do and Know
*** The implementation of if-then-else structure in MATLAB
*** The implementation of for and while loops in MATLAB
*** The implementation of switch case structures in MATLAB
*** The implementation of if-then-else structures in MATLAB
** Worth Being Familiar with
*** General use of MATLAB
*** Calculus I
*** Calculus II
Assessment of Learning
* Formative Assessment
** In Lab (groups)
*** Pretest
*** Solution to in-lab assignment
** Homework (individual)
*** Solution to homework problems
*** Solution to quizzes
* Summative Assessment
** Solution to challenge
** Post test
** Problem on final exam

## Legacy Cycle

OBJECTIVE
By the next class period, students will be able to:
* Program loop structures using MATLAB
* Program condition structures using MATLAB
The objectives will require that students be able to:
* Use FOR and WHILE loop structures in MATLAB
* Use IF-THEN-ELSE structures in MATLAB
* Use SWITCH structures in MATLAB
THE CHALLENGE
If you could only draw using pixels, how could you generate a horizontal line? A diagnonal line? A rectangle?
GENERATE IDEAS
* Students will be asked to use grid paper to practice the basic steps required to draw the representation of a line using dots in place of pixels.
* Students will be tasked to document the basic steps they performed.
* The students will be tasked to translate the basic steps into logic.
MULTIPLE PERSPECTIVES
Student will brainstorm and share their methods.
RESEARCH & REVISE
Students will be given a variety of questions or a rubric to assess which of the methods discussed in their group is optimal in terms of programming. They will have to choose a method amongst the ones discussed.
TEST YOUR METTLE
The students will be asked to draw a box that is crossed out (i.e. a rectangle with two diagonal lines connecting opposite corners).
GO PUBLIC
The students will have to share their code. They will then be assessed by the class based on the previously mentioned rubric.

## Pre-Lesson Quiz

* How might you conduct a repetitive process algorithmically?
* Give an example of a repetitive process?
* Describe two distinct ways in which a process might terminate?
* Are you aware of specific programming structures for automating logic decisions? If so, name them.
* How can you algorithmically implement the logic of a decision process?

## Test Your Mettle Quiz

* What method(s) is/are best suited for conducting repetitive tasks?
* What is the difference between for and do (while) loops?
* What is the difference between a condition statement (if-then-else) and a switch?
* Give an example of where a switch statement might be preferred over an if-then-else statement?