Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.

Similar presentations


Presentation on theme: "Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis."— Presentation transcript:

1 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis Chapter 2: Input, Processing, and Output

2 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-2 Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types 2.5 Named Constants 2.6 Hand Tracing a Program 2.7 Documenting a Program

3 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-3 2.1 Designing a Program 1.The first step in programming is designing – flowcharts and pseudocode help with this process. 2.Next, the code is written. 3.All code must be cleared of all syntax errors. 4.After the executable is created, it can be checked for logic errors. 5.If logic errors exist, the program must be debugged.

4 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-4 2.1 Designing a Program The purpose of Programming Logic and Design is to focus on Flowcharts and Pseudocode. The design is the foundation of a good program. Figure 2-1 The program development cycle

5 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-5 2.1 Designing a Program Two steps in designing a program 1.Understand the tasks that the program is to perform. Learning what the customer wants. 2.Determine the steps that must be taken to perform the task. Create an algorithm, or step-by-step directions, to solve the problem. Use flowcharts and/or pseudocode to solve.

6 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Class Research: 15 minutes for each team to research 5 minutes for each team to present Use your books, the internet and the ITT Tech Virtual Library to determine: What is pseudocode? What is a flowchart? What are each used for? Discuss pros and cons of each 1-6

7 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-7 2.1 Designing a Program Pseudocode Fake code used as a model for programs No syntax rules Well written pseudocode can be easily translated to actual code Display “Enter the number of hours” Input hours Display “Enter the hourly pay rate” Input payRate Set grossPay = hours * payRate Display “The gross pay is $”, grossPay

8 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-8 2.1 Designing a Program Flowcharts A diagram that graphically depicts the steps that take place in a program Terminator used for start and stop Parallelogram used for input and output Rectangle used for processes Figure 2.2 Flowchart for the pay calculating program

9 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-9 2.2 Output, Input, and Variables Output – data that is generated and displayed Input – data that a program receives Variables – storage locations in memory for data Computer programs typically follow 3 steps 1.Input is received 2.Some process is performed on the input 3.Output is produced

10 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-10 2.2 Output, Input, and Variables Display is the keyword to show output to the screen Sequence – lines execute in the order they appear String Literals – a sequence of characters Figure 2-5 Output of Program 2-1 Figure 2-4 The statements execute in order

11 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-11 2.2 Output, Input, and Variables Input is the keyword to take values from the user of the program It is usually stored in variables

12 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley BREAK 10 minutes 1-12

13 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-13 2.2 Output, Input, and Variables Programmers can define variable names following certain rules –Must be one word, no spaces –Generally, punctuation characters are avoided –Generally, the first character cannot be a number –Name a variable something that indicates what may be stored in it camelCase is popular naming convention

14 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-14 2.3 Variable Assignment & Calculations Variable assignment does not always have to come from user input, it can also be set through an assignment statement Set price = 20

15 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-15 2.3 Variable Assignment & Calculations Calculations are performed using math operators The expression is normally stored in variables Set sale = price – discount Table 2-1 Common math operators

16 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley BREAK 10 minutes 1-16

17 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Multiple Choice Review Questions 1 - 10 Take good notes. Some of these questions might show up on the mid-term. 1-17

18 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 1 A ______ error does not prevent the program from running, but causes it to produce incorrect results. a.syntax b.hardware c.logic d.fatal 1-18

19 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 1 A ______ error does not prevent the program from running, but causes it to produce incorrect results. a.syntax b.hardware c.logic d.fatal 1-19

20 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 2 A ______ is a single function that the program must perform in order to satisfy the customer. a.task b.software requirement c.prerequisite d.predicate 1-20

21 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 2 A ______ is a single function that the program must perform in order to satisfy the customer. a.task b.software requirement c.prerequisite d.predicate 1-21

22 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 3 A(n) ______ is a set of well-defined logical steps that must be taken to perform a task. a.logarithm b.plan of action c.logic schedule d.algorithm 1-22

23 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 3 A(n) ______ is a set of well-defined logical steps that must be taken to perform a task. a.logarithm b.plan of action c.logic schedule d.algorithm 1-23

24 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 4 An informal language that has no syntax rules, and is not meant to be compiled or executed is called ______. a.faux code b.pseudocode c.java d.a flowchart 1-24

25 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 4 An informal language that has no syntax rules, and is not meant to be compiled or executed is called ______. a.faux code b.pseudocode c.java d.a flowchart 1-25

26 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 5 A ______ is a diagram that graphically depicts the steps that take place in a program. a.flowchart b.step chart c.code graph d.program graph 1-26

27 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 5 A ______ is a diagram that graphically depicts the steps that take place in a program. a.flowchart b.step chart c.code graph d.program graph 1-27

28 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 6 A(n) ______ is a set of statements that execute in the order that they appear. a.serial program b.sorted code c.sequence structure d.ordered structure 1-28

29 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 6 A(n) ______ is a set of statements that execute in the order that they appear. a.serial program b.sorted code c.sequence structure d.ordered structure 1-29

30 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 7 A ______ is a sequence of characters that is used as data. a.sequence structure b.character collection c.string d.text block 1-30

31 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 7 A ______ is a sequence of characters that is used as data. a.sequence structure b.character collection c.string d.text block 1-31

32 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 8 A ______ is a storage location in memory that is represented by a name. a.variable b.register c.ram slot d.byte 1-32

33 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 8 A ______ is a storage location in memory that is represented by a name. a.variable b.register c.ram slot d.byte 1-33

34 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 9 A ______ is any hypothetical person that is using a program and providing input to it. a.designer b.user c.guinea pig d.test subject 1-34

35 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 9 A ______ is any hypothetical person that is using a program and providing input to it. a.designer b.user c.guinea pig d.test subject 1-35

36 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 10 A(n) ______ is a message that tells (or asks) the user to enter a specific value. a.inquiry b.input statement c.directive d.prompt 1-36

37 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Question 10 A(n) ______ is a message that tells (or asks) the user to enter a specific value. a.inquiry b.input statement c.directive d.prompt 1-37

38 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Unit 2 Homework Short Answer Review Questions 1-4 on page 71 of the textbook Algorithm Workbench Review Questions 1 & 2 on page 71 of the textbook Programming Exercises Questions 1 & 4 starting on page 72 of the textbook DUE NEXT WEEK 1-38

39 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley BREAK 10 minutes 1-39

40 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Preparing Your Laptop for the Course Passport device should be divided into 4 partitions for: –Your own files (200GB) –Windows (100GB) –Linux (100GB) –Windows 2008 Server (100GB) 1-40

41 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Preparing Your Laptop for the Course (cont) Copy VMPlayer files to Passport devices See VM Player instruction sheet (PT1420.U1.TS1) Download vbsetup.exe from Wikispace web site Download Raptor files from Wikispace web site  Autorun.inf  Raptor_Setup.msi  Start_Here.html 1-41

42 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley BREAK 10 minutes 1-42

43 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Labs See Lab Manual Handout 2.1 Pseudocode See Lab Manual Handout 2.2 Flowchart See Lab Manual Handout 2.3 Visual Basic 1-43

44 Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Due Next Week vs Today Due Next Week Unit 2 Research Assignment: Researching Variable Naming Rules (see handout) Unit 2 Homework (see handout) Read the rest of Chapter 2 (pp. 56-68) Due today Lab 2.1, Lab 2.2, and Lab 2.3 1-44


Download ppt "Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis."

Similar presentations


Ads by Google