Starting Out with Programming Logic and Design, Third Edition, is a language-independent introductory programming book that orients students to programming concepts and logic without assuming any previous programming experience. In the successful, accessible style of Tony Gaddis' best-selling texts, useful examples and detail-oriented explanations allow students to become comfortable with fundamental concepts and logical thought processes used in programming without the complication of language syntax. Students gain confidence in their program design skills to transition into more comprehensive programming courses.The book is ideal for a programming logic course taught as a precursor to a language-specific introductory programming course, or for the first part of an introductory programming course.
Les mer
Preface xiiiChapter 1 Input, Processing, and Output 292.1 Designing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.2 Output, Input, and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.3 Variable Assignment and Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . 43IN THE SPOTLIGHT: Calculating a Percentage . . . . . . . . . . . . . . . . . . . . . . . . . . . 47IN THE SPOTLIGHT: Calculating an Average . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50IN THE SPOTLIGHT: Converting a Math Formula to aProgramming Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532.4 Variable Declarations and Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 562.5 Named Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622.6 Hand Tracing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632.7 Documenting a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64IN THE SPOTLIGHT: Using Named Constants, Style Conventions,and Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72Chapter 2 Modules 753.1 Introduction to Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753.2 Defining and Calling a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78IN THE SPOTLIGHT: Defining and Calling Modules . . . . . . . . . . . . . . . . . . . . . . . 843.3 Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883.4 Passing Arguments to Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90IN THE SPOTLIGHT: Passing an Argument to a Module . . . . . . . . . . . . . . . . . . . . 95IN THE SPOTLIGHT: Passing an Argument by Reference . . . . . . . . . . . . . . . . . . . 1003.5 Global Variables and Global Constants . . . . . . . . . . . . . . . . . . . . . . . . . 104IN THE SPOTLIGHT: Using Global Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Chapter 3 Decision Structures and Boolean Logic 1154.1 Introduction to Decision Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115IN THE SPOTLIGHT: Using the If-Then Statement . . . . . . . . . . . . . . . . . . . . . . . 1224.2 Dual Alternative Decision Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 125IN THE SPOTLIGHT: Using the If-Then-Else Statement . . . . . . . . . . . . . . . . . . 1264.3 Comparing Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1314.4 Nested Decision Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135IN THE SPOTLIGHT: Multiple Nested Decision Structures . . . . . . . . . . . . . . . . . 1384.5 The Case Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142IN THE SPOTLIGHT: Using a Case Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1454.6 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1474.7 Boolean Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159Chapter 4 Repetition Structures 1635.1 Introduction to Repetition Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 1635.2 Condition-Controlled Loops: While, Do-While, and Do-Until . . . . . . 164IN THE SPOTLIGHT: Designing a While Loop . . . . . . . . . . . . . . . . . . . . . . . . . . 169IN THE SPOTLIGHT: Designing a Do-While Loop . . . . . . . . . . . . . . . . . . . . . . . . 1785.3 Count-Controlled Loops and the For Statement . . . . . . . . . . . . . . . . . 183IN THE SPOTLIGHT: Designing a Count-Controlled Loopwith the For Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1915.4 Calculating a Running Total . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2015.5 Sentinels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205IN THE SPOTLIGHT: Using a Sentinel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2065.6 Nested Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214Chapter 5 Functions 2176.1 Introduction to Functions: Generating Random Numbers . . . . . . . . . . 217IN THE SPOTLIGHT: Using Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 221IN THE SPOTLIGHT: Using Random Numbers to Represent Other Values . . . . . 2236.2 Writing Your Own Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225IN THE SPOTLIGHT: Modularizing with Functions . . . . . . . . . . . . . . . . . . . . . . . 2326.3 More Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253Chapter 6 Input Validation 2577.1 Garbage In, Garbage Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2577.2 The Input Validation Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258IN THE SPOTLIGHT: Designing an Input Validation Loop . . . . . . . . . . . . . . . . . . 2607.3 Defensive Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268Chapter 7 Arrays 2698.1 Array Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269IN THE SPOTLIGHT: Using Array Elements in a Math Expression . . . . . . . . . . . 2768.2 Sequentially Searching an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2838.3 Processing the Contents of an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . 289IN THE SPOTLIGHT: Processing an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2968.4 Parallel Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303IN THE SPOTLIGHT: Using Parallel Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3048.5 Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307IN THE SPOTLIGHT: Using a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . 3118.6 Arrays of Three or More Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . 316Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320Chapter 8 Sorting and Searching Arrays 3239.1 The Bubble Sort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323IN THE SPOTLIGHT: Using the Bubble Sort Algorithm . . . . . . . . . . . . . . . . . . . . 3309.2 The Selection Sort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3379.3 The Insertion Sort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3439.4 The Binary Search Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349IN THE SPOTLIGHT: Using the Binary Search Algorithm . . . . . . . . . . . . . . . . . . . 353Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358Chapter 9 Files 36110.1 Introduction to File Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . 36110.2 Using Loops to Process Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373IN THE SPOTLIGHT: Working with Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37810.3 Using Files and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38310.4 Processing Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384IN THE SPOTLIGHT: Adding and Displaying Records . . . . . . . . . . . . . . . . . . . . . 388IN THE SPOTLIGHT: Searching for a Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392IN THE SPOTLIGHT: Modifying Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394IN THE SPOTLIGHT: Deleting Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39810.5 Control Break Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401IN THE SPOTLIGHT: Using Control Break Logic . . . . . . . . . . . . . . . . . . . . . . . . .403Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410Chapter 10 GUI Applications and Event-Driven Programming 54915.1 Graphical User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54915.2 Designing the User Interface for a GUI Program . . . . . . . . . . . . . . . . . . 552IN THE SPOTLIGHT: Designing a Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55715.3 Writing Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559IN THE SPOTLIGHT: Designing an Event Handler . . . . . . . . . . . . . . . . . . . . . . . . 562Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566Index 573
Les mer

Produktdetaljer

ISBN
9780132805452
Publisert
2012-03-15
Utgave
3. utgave
Utgiver
Vendor
Pearson
Vekt
1060 gr
Høyde
254 mm
Bredde
203 mm
Dybde
22 mm
Aldersnivå
08, UF
Språk
Product language
Engelsk
Format
Product format
Kombinasjonsprodukt
Antall sider
648

Forfatter

Biographical note

Tony Gaddis is the principal author of theStarting Out With . . . series of textbooks. Tony has twenty years of experience teaching computer science courses, primarily at Haywood Community College. He is a highly acclaimed instructor who was previously selected as the North Carolina Community College "Teacher of the Year" and has received the Teaching Excellence award from the National Institute for Staff and Organizational Development. The Starting Out With . . . series includes introductory books covering Programming Logic and Design, C++, Java, Microsoft (R) Visual Basic, C# (R), Python, and Alice, all published by Pearson Addison-Wesley.