Computers and Logic -...

10
Computers and Logic Programming - The process Understand the problem and requirements Design or select an algorithm to solve it Express (code) the algorithm in a programming language (e.g., C) Test and debug the program until it works and meets the requirements Programming - The mechanics Lego Programming C++ Programming 1

Transcript of Computers and Logic -...

Page 1: Computers and Logic - faculty.cse.tamu.edufaculty.cse.tamu.edu/slupoli/notes/UML/old/UML-Comput…  · Web viewDesign or select an algorithm to solve it . Express (code) the algorithm

Computers and Logic

Programming - The process Understand the problem and requirements Design or select an algorithm to solve it Express (code) the algorithm in a programming language (e.g., C) Test and debug the program until it works and meets the requirements

Programming - The mechanics Lego Programming

C++ Programming

1

Page 2: Computers and Logic - faculty.cse.tamu.edufaculty.cse.tamu.edu/slupoli/notes/UML/old/UML-Comput…  · Web viewDesign or select an algorithm to solve it . Express (code) the algorithm

FlowchartingSymbol Name Meaning

Flow line used to connect symbols and indicate the flow of logic

Terminal used to represent the beginning (START) or end (END) of a task

Input/Output used for input and output operations, such as reading in from the keyboard (user input) or outputting to the screen

Processing used for arithmetic, code, and data manipulations. Multiple lines can be placed in one of these.

Decision used for ANY logical comparison like if/else, <, >, &&, ||, !, etc…

Connector if you have multiple pages, place a number inside this symbol so it can match another with the same number

Predefined Process/Method

used to represent a method call, or variables are sent to another method to return data or an answer

Note/Annotation used to add personal notes to your project

ALL IN MICROSOFT WORD!!!o Drawing Autoshapes Flowchart

2

Page 3: Computers and Logic - faculty.cse.tamu.edufaculty.cse.tamu.edu/slupoli/notes/UML/old/UML-Comput…  · Web viewDesign or select an algorithm to solve it . Express (code) the algorithm

Example:

Create a Flowchart the given “honey do” list1.    Spouse says “Cut the grass.”2.     Open garage door3.     Pull weed eater to driveway4.     Check gas and oil5.                        Need gas or oil?6.                        Get gas & oil from garage.(branches from decision merge here)

7.                        Start weed eater8.                        Weed eat the yard9.                        Turn weed eater off10.                        Put in gas and oil as needed11.                        Put weed eater away12.         Close garage13.    Check oil and fill gas in mower14.    Cut the grass15.     Does lawnmower need to be

washed?16.     Get hose and wash mower.(branches from decision merge here)17.     Return mower to garage

3

Page 4: Computers and Logic - faculty.cse.tamu.edufaculty.cse.tamu.edu/slupoli/notes/UML/old/UML-Comput…  · Web viewDesign or select an algorithm to solve it . Express (code) the algorithm

Example If-decisions flowchart setups

YES NO

NO YES NO

YES NO

YES NO

YES NO

Drawing Flowcharts As much as possible draw from the top of the page towards the bottom

o There will be times that it will be difficult, but remember to make an effort

4

if grade > 59

Pass!!! Fail!!!

grade > 59

grade > 69

grade > 79

grade > 89

grade > 99

F

D

C

B

A

Page 5: Computers and Logic - faculty.cse.tamu.edufaculty.cse.tamu.edu/slupoli/notes/UML/old/UML-Comput…  · Web viewDesign or select an algorithm to solve it . Express (code) the algorithm

Lego Robot Flowchart ExerciseExample:Move robot forward for 3 seconds, stop and beep 3 times

Notice the pink squares below:

A B C D E F

1

2(3 seconds) (left or right)

3(3 seconds)

(reset & read)

Loop

5

Page 6: Computers and Logic - faculty.cse.tamu.edufaculty.cse.tamu.edu/slupoli/notes/UML/old/UML-Comput…  · Web viewDesign or select an algorithm to solve it . Express (code) the algorithm

Using what you learned, create a flowchart (on the picture below) to have the robot move forward one rotation, beep 3 time, turn left 90 degrees move forward for 3 seconds and stop.

Lego Mindstorms creating programs that look like flowcharts always start off blank, with the START at the left of the screen drop icons on the screen (next to start) to program notice flowline connects icons together

6