CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.

Slides:



Advertisements
Similar presentations
2.1 Program Construction In Java
Advertisements

CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2012.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2010.
CSE 113 Introduction to Computer Programming Lecture slides for Week 10 Monday, October 31 th, 2011 Instructor: Scott Settembre.
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CSE 113 Introduction to Computer Programming Lecture slides for Week 12 Monday, November 14 th, 2011 Instructor: Scott Settembre.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
CS 122 / CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CS 123 Engineering Computation Lab Lab 2 Dan De Sousa and Bruce Char Department of Computer Science Drexel University April 2009 ©By the author. All rights.
© The McGraw-Hill Companies, 2006 Chapter 2 Selection.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS122/CS123 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Summer 2011.
CS122 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS 123 Lab 4 Instructor: Mark Boady Course Designer: Professor Bruce Char Department of Computer Science Drexel University Spring 2013.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS122 / CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
Python 101 Dr. Bernard Chen University of Central Arkansas PyArkansas.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
CS123 Engineering Computation Lab Lab 1 Section Instructor: Mark Boady Content By: Bruce Char Department of Computer.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS 121 – Quiz Feb 17 th. Question 2 We want to count how many days there were such that the temperature is at least degrees lower than the.
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2012.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter, 2011 ©By the author. All rights reserved.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
CS 122 Engineering Computation Lab Lab 4 Dan De Sousa and Bruce Char Department of Computer Science Drexel University Summer 2009 ©By the author. All rights.
Week 4 Program Control Structure
CS123 Engineering Computation Lab Lab 2 Instructor: Mark Boady Content By: Bruce Char Department of Computer Science Drexel University.
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
Introduction to Computing Concepts Note Set 14. What if… You had to print “I love Java” to the screen 125 times. How? 125 lines of ▫ System.out.println(“I.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2013.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS122 – Quiz 2 Winter, 2013 Quiz Hints. Quiz 2 Hints Question 1 – working with the “if” statement  First, we did not fully explain the structure of the.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Winter 2010.
CS123 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Spring 2013.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2011.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS 122 Engineering Computation Lab Lab1 Bruce Char Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission.
CS 122/CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
CS122 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Winter 2013.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS122 Engineering Computation Lab Lab 4
CS 121 Engineering Computation Lab Lab 3
CS123 Engineering Computation Lab Lab 4
Introduction to Programming
Think What will be the output?
CS122 Engineering Computation Lab Lab 3
CS 121 Engineering Computation Lab Lab 3
Review of Previous Lesson
CprE 185: Intro to Problem Solving (using C)
Presentation transcript:

CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011

Review of Lab 2 Cycle Lab 2 – pre lab quizlet, lab 2 and quiz 2 completed along with pre lab 3 quizlet –Quizlet will remain open through Wednesday at 8 AM –Quiz grades to be issued this week Major Lab 2 concepts to remember –Use of user defined functions to create plots of boxes –Introduction to Maple’s table and for loop features

Review of Lab 2 Cycle drawBoxB function syntax: –drawBoxB:=(width, height, xlo, ylo,c)  display([line([xlo,ylo],[xlo+width,ylo],color=c), line([xlo+width,ylo],[xlo+width,ylo+height],color=c), line([xlo,ylo],[xlo,ylo+height],color=c), line([xlo,ylo+height],[xlo+width,ylo+height],color=c)], axes=none, scaling=constrained);

Review of Lab 2 Cycle Maple table and for loop usage in the chemical reaction problem –Atab:=table(); –indexTab:=table(); –for i from 1 to 50 do indexTab[i] := i; # note use of for loop counter I Atab[i] := ………..; Etc. –end do; –# remember to convert tables to lists before using in plot functions –# since these functions expect a list type parameter

Administrative Notes Please continue to contact your individual instructors with questions and problems Special Accommodations –If you are eligible for extended time for the proficiency exam, please provide a copy of the form to your instructor

Lab 3 Overview Based on materials from Chapter 14 and 15 readings –Chapter 14 – More on repetition and looping “while” loop – conditional looping + relational operators Combining “for” and “while” loops Dealing with runaway (infinite) “while” loops –Chapter 14 – Conditional execution Choosing alternatives – if.. then.. else.. elif constructs

Lab 3 Overview Lab 3 outline –Part 1 – Analysis of Blammo trajectory options Applying a “for” loop to calculate Blammo’s distance for a variety of firing angles – starter script provided 1.2 – Finding the smallest firing angle for Blammo to achieve a particular flight distance 1.3 – Find all firing angles that enables Blammo to hit target 1.4 – Plot a movie (animation) of all trajectories for different firing angles

Lab 3 Maple Concepts: Discussion Conditional looping with “while” loops –while (condition) do loop body –end do; –The loop body will continue to get executed as long as the condition = true –The condition expression usually utilizes 1 or more relational operator ( >= <> = ) –Sometimes, a variable in the condition expression must be initialized so that it will have a value for the 1 st condition test –Faulty program logic can result in an endless (infinite) loop Use “stop (red)” hand on Maple icon list If this does not stop the execution, use “Force quit” from the Maple menu

Lab 3 Maple Concepts: Discussion “while” loops - continued –“while” and “for” loops can be used in combine when you want to potentially loop over a series of values, but also want to stop when a certain condition is met. –ex.  for angle from 0 to 90 while (cos >= sin) do This loop has the potential to loop 91 times But will stop looping once cos < sin. In some iteration (angle = 45), the cos and sin will become equal. Before, the cos is > sin and after, the cos < sin. Therefore, this loop will execute 46 times, for angles of 0 through 45

Lab 3 Maple Concepts: Discussion Choosing among alternative actions – “if” statement –if (condition) then Code to execute if condition is true –end if; –if (condition) then Code to execute if condition is true –else Code to execute if condition is false –end if; –Many examples in chapter readings and lab

Lab 3 Maple Concepts: Discussion Animation / Movie basics An animation is actually a series of “snapshot” plots which are displayed one by one to give the appearance of a continuous “movie” –“insequence=true” in the display function designates the plots as an animated sequence –When executed, the initial plot in the sequence appears on the screen. By “right-clicking” on this plot and selecting Animate  Play The animation will run (see Part0 for example animation) Note the overall syntax and order of operations in the demo example!

Lab 3 Maple Concepts: Part 0 Exercises Part 0 will provide practice for some of the Maple features needed for this lab –The following concepts are illustrated Example 1 – produce table of sine and cosines functions for angles from 0 to 90 degrees Example 2 – script to find and report the angle between 0 and 90 degrees for which the sine and cosine are equal Example 3 – produce table of sines and cosines for angles between 0 to 90 where cosine is greater than sine Example 4 – Create a movie of sine and cosine values for 0 through 90 degrees

Quiz Week (6) Activities Quiz 3 will be released on Friday (5/6) at 6 PM –Deadline: Wednesday (5/11) at 4:30 PM –Makeup quiz – from Thursday (5/12) at 9 AM through Sunday (5/15) at 11:00 PM 30% penalty Pre-lab 4 quizlet –From Thursday (5/12 – 9 AM) through Monday (5/16 – 8 AM) Be sure to visit the CLC for quiz assistance