Top Banner
INTRODUCTION TO LOGIC AND DESIGN
11

INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

Apr 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

INTRODUCTION TO LOGIC AND DESIGN

Page 2: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

THE PROGRAM DEVELOPMENT CYCLE

• Understand the problem

• Plan the logic

• Code the program

• Use software (a compiler or

interpreter) to translate the program

into machine language

• Test the program

• Put the program into production

• Maintain the program

These are the two most difficult steps.

Page 3: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

SIMPLE PROGRAM LOGIC

ERRORS

• Syntax errors are errors with code

• These errors will not allow your

program to compile and run

• Logic Errors are errors that produce

incorrect results

• These are more difficult to find and fix

BASIC LOGIC – SUPPOSE YOU WANT TO BAKE A CAKE

Get a bowl

Stir

Add two eggs

Add a gallon of gasoline

Back a 350 degrees for 45

minutes

Add three cups of flower

Don’t do this when

baking a cake

This step is out of

order

Page 4: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

TWO TRUTHS AND A LIE

1. Hardware is the equipment, or the devices associated with a computer.

Software is computer instructions

2. The grammar rules of a computer programming language are its syntax

3. You write programs using machine language, and translation software

converts the statements to programming language.

You write programs in a high level language like

java or python and a translator will convert the

statements to machine language

Page 5: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

USING PSEUDOCODE AND FLOWCHARTS

• Programmers use two tools when planning the logic and flow of a program

• Pseudocode and Flowcharts

• Pseudocode is an English-like representation of the logical steps for solving a

problem

• A flowchart is a pictorial representation of the same thing.

Page 6: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

PSEUDOCODE FOR A NUMBER DOUBLING PROBLEM

start

input myNumber

set myAnswer = myNumber * 2

output myAnswer

stop

Many programmers use begin and end

Some might write get myNumber or

calculate my answer

Some might say display myAnswer

The words used to dictate the logic are not as important as the logic itself.

Don’t get hung up on what to say, but make sure what you have written

works

Page 7: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

DRAWING FLOWCHARTS

• In creating a flow chart you use geometric symbols connected by flow lines to

depict your logic

• A few basic symbols that every flow chart will have include:

• Terminal Symbols

• Input Symbol

• Processing Symbol

• Output Symbol

• Decision Symbol

Notice the input and output

symbols are the same. It is

often called the input/output

symbol or I/O symbol

Page 8: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

THE NUMBER DOUBLING PROBLEM

Page 9: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

TWO TRUTHS AND A LIE

1. When you draw a flowchart, you use a parallelogram to represent an input

operation

2. When you draw a flowchart, you use a parallelogram to represent a

processing operation

3. When you draw a flowchart, you use a parallelogram to represent an

output operation.

When you draw a flowchart, you use a rectangle

to represent processing operations

Page 10: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

PRACTICE

• Draw a flow chart and write the pseudocode to represent the logic of a

program that allows the user to enter a value for the radius of a circle. The

program the calculates the diameter by multiplying the radius by 2 and then

calculates the circumference by multiplying the diameter by 3.14. The

program then should output both results.

Page 11: INTRODUCTION TO LOGIC AND DESIGNpehs.psd202.org/documents/kspencer/1506425370.pdf•Programmers use two tools when planning the logic and flow of a program •Pseudocode and Flowcharts

HOMEWORK

• Write the process involved in creating a Peanut Butter and Jelly Sandwich.

• The directions need to be specific enough that someone who has never done

this or even seen a PB & J could perform this task.