Chapter 2: Input, Processing, and Output

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Introduction to Flowcharting
Introduction to Flowcharting
Programming Logic and Design Fourth Edition, Introductory
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
Chapter 2- Visual Basic Schneider
COSC 120 Computer Programming
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 1 Program Design
Chapter 3 Planning Your Solution
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Simple Program Design Third Edition A Step-by-Step Approach
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 6 Value-Returning.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 5 Functions.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 3 Simple.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Input, Output, and Processing
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
1 Program Planning and Design Important stages before actual program is written.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 5 Repetition Structures.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
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.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Chapter 2: Input, Processing, and Output Starting Out with Programming Logic & Design by Tony Gaddis (with instructor modifications) 1-1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Algorithms and Flowcharts
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Topics Designing a Program Input, Processing, and Output
Input and Output Upsorn Praphamontripong CS 1110
Chapter 2: Input, Processing, and Output
The Selection Structure
Introduction to Flowcharting
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.
Chapter 2- Visual Basic Schneider
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
An Introduction to Programming with C++ Fifth Edition
Chapter 2: Input, Processing, and Output
Programming Logic and Design Eighth Edition
Presentation transcript:

Chapter 2: Input, Processing, and Output Starting Out with Programming Logic & Design First Edition by Tony Gaddis

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

2.1 Designing a Program The first step in programming is designing – flowcharts and pseudocode help with this process. Next, the code is written. All code must be cleared of all syntax errors. After the executable is created, it can be checked for logic errors. If logic errors exist, the program must be debugged.

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

2.1 Designing a Program Two steps in designing a program Understand the tasks that the program is to perform. Learning what the customer wants. 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.

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

2.1 Designing a Program Flowcharts Figure 2.2 Flowchart for the pay calculating 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

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 Input is received Some process is performed on the input Output is produced

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-4 The statements execute in order Figure 2-5 Output of Program 2-1

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

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

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

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

2.4 Variable Declarations & Data Types A variable declaration includes a variable’s name and a variable’s data type Data Type – defines the type of data you intend to store in a variable Integer – stores only whole numbers Real – stores whole or decimal numbers String – any series of characters Declare Real grossPay

2.4 Variable Declarations & Data Types For safety and to avoid logic errors, variables should be initialized to 0 or some other value

2.5 Named Constants A named constant is a name that represents a value that cannot be changed Makes programs more self explanatory If a change to the value occurs, it only has to be modified in one place Constant Real INTEREST_RATE = 0.069

2.6 Hand Tracing a Program Hand tracing is a simple debugging process for locating hard to find errors in a program Involves creating a chart with a column for each variable, and a row for each line of code Figure 2-14 Program with the hand trace chart completed

2.7 Documenting a Program External documentation describes aspects of the program for the user, sometimes written by a technical writer Internal documentation explains how parts of the program works for the programmer, also known as comments // comments are often distinguished within // the program with line comments