copyright © 2012 pearson education, inc. chapter 2 beginning problem-solving concepts for the...

32
Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition By Maureen Sprankle and Jim Hubbard

Upload: benjamin-garrett

Post on 22-Dec-2015

241 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Chapter 2Beginning Problem-SolvingConcepts for the Computer

Problem Solving and Programming Concepts

9th Edition

By Maureen Sprankle and Jim Hubbard

Page 2: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc. 0-2

Overview

• Constants and Variables• Data Types• How the Computer Stores Data• Functions• Operators• Expressions and EquationsBullet, etc

Page 3: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Figure 2.1 Important Concepts to Learn

0-3

Page 4: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.1 Constants and Variables on the Computer

0-4

Page 5: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.1 Constants and Variables on the Computer

0-5

Page 6: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Rules for Naming and Using Variables

1. Name a variable according to what it represents.

2. Do not use spaces.

3. Start a variable name with a letter.

4. Do not use a dash or any other symbol that is used as a mathematical operator.

0-6

Page 7: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Rules for Naming and Using Variables

5. Consistent usage of variable name.

6. Consistent use of upper, lowercase characters in variable names

7. Use naming convention specified by your company

0-7

Page 8: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.2 Incorrect Variable Names

0-8

Page 9: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Figure 2.2 Processing Data—How a Computer Balances a Checkbook

0-9

Page 10: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.3 Data Types and Their Data Sets

0-10

Page 11: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.4 Examples of Data Types

0-11

Page 12: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.4 Examples of Data Types

0-12

Page 13: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.5 Functions

0-13

Page 14: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.5 Functions

0-14

Page 15: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.5 Functions

0-15

Page 16: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.5 Functions

0-16

Page 17: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.6 Operators and Their Computer Symbols

0-17

Page 18: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.6 Operators and Their Computer Symbols

0-18

Page 19: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.7 Definitions of the Logical Operators

0-19

Page 20: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.7 Definitions of the Logical Operators

0-20

Page 21: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.7 Definitions of the Logical Operators

0-21

Page 22: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.8 Hierarchy of Operations

0-22

Page 23: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.8 Hierarchy of Operations

0-23

Page 24: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Table 2.9 Expressions and Equations

0-24

Page 25: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Evaluating a Mathematical Expression

0-25

Page 26: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Evaluating a Relational Expression

0-26

Page 27: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Evaluating a Logical Expression

0-27

Page 28: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Evaluating an Equation That Uses Both Relational and Logical Operators

0-28

Page 29: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Developing a Table of All PossibleResultants of a Logical Expression

• One unknown—A. • Two combinations: A can be either True or

False.

0-29

Page 30: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Developing a Table of All PossibleResultants of a Logical Expression

• Two unknowns—A and B. • Four combinations: B can be either True or

False for each value of A..

0-30

Page 31: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Developing a Table of All PossibleResultants of a Logical Expression

• Three unknowns—A, B, and C. • Eight combinations.

0-31

Page 32: Copyright © 2012 Pearson Education, Inc. Chapter 2 Beginning Problem-Solving Concepts for the Computer Problem Solving and Programming Concepts 9 th Edition

Copyright © 2012 Pearson Education, Inc.

Developing a Table of All PossibleResultants of a Logical Expression

0-32