Skip to content Skip to sidebar Skip to footer

Programming Logic and Design Chapter 7 Review Questions Answers

Starting Out with Programming Logic and Design: Pearson New International Edition


3e édition

VitalSource eBook (VitalBook) - La commande de ce produit n'est pas disponible dans votre pays, pour commander depuis votre pays, cliquez ici. This production is not bachelor in your country, to buy from your country, click here.

Spécifications


Éditeur
Pearson Teaching
Édition
3
Auteur
Tony Gaddis,
Langue
anglais
BISAC Subject area Heading
COM014000 COMPUTERS / Information science > COM051000 COMPUTERS / Programming > COM051230 COMPUTERS / Software Development and Engineering
BIC field of study category (UK)
UM Reckoner programming / software evolution > UY Computer science
Code publique Onix
05 Enseignement supérieur
Engagement de première publication du titre
28 octobre 2013
Subject Scheme Identifier Code
Classification thématique Thema: Informatique
Classification thématique Thema: Programmation informatique / génie logiciel

VitalSource eBook


Date de publication
28 octobre 2013
ISBN-thirteen
9781292053080
Ampleur
Nombre de pages de contenu principal : 442
Code interne
1292053089
Protection technique east-livre
DRM

Google Livres Aperçu


Sommaire


Preface 13
Chapter i Introduction to Computers and Programming 1
ane.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 How Computers Store Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1.4 How a Program Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.5 Types of Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Chapter 2 Input, Processing, and Output 29
2.1 Designing a Programme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
two.ii Output, Input, and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
two.3 Variable Consignment and Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . 43
IN THE SPOTLIGHT: Computing a Percentage . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
IN THE SPOTLIGHT: Calculating an Boilerplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . fifty
IN THE SPOTLIGHT: Converting a Math Formula to a
Programming Argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.4 Variable Declarations and Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
two.5 Named Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.half dozen Manus Tracing a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
two.7 Documenting a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
IN THE SPOTLIGHT: Using Named Constants, Way Conventions,
and Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Chapter 3 Modules 75
3.1 Introduction to Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3.ii Defining and Calling a Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
IN THE SPOTLIGHT: Defining and Calling Modules . . . . . . . . . . . . . . . . . . . . . . . 84
three.3 Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
iii.4 Passing Arguments to Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
IN THE SPOTLIGHT: Passing an Argument to a Module . . . . . . . . . . . . . . . . . . . . 95
IN THE SPOTLIGHT: Passing an Argument by Reference . . . . . . . . . . . . . . . . . . . 100
3.v Global Variables and Global Constants . . . . . . . . . . . . . . . . . . . . . . . . . 104
IN THE SPOTLIGHT: Using Global Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Chapter 4 Conclusion Structures and Boolean Logic 115
4.1 Introduction to Decision Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
IN THE SPOTLIGHT: Using the If-Then Argument . . . . . . . . . . . . . . . . . . . . . . . 122
four.two Dual Culling Decision Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
IN THE SPOTLIGHT: Using the If-So-Else Argument . . . . . . . . . . . . . . . . . . 126
4.3 Comparing Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
four.4 Nested Determination Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
IN THE SPOTLIGHT: Multiple Nested Decision Structures . . . . . . . . . . . . . . . . . 138
iv.5 The Case Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
IN THE SPOTLIGHT: Using a Case Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
iv.six Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
iv.7 Boolean Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Chapter 5 Repetition Structures 163
v.ane Introduction to Repetition Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 163
5.2 Condition-Controlled Loops: While, Do-While, and Do-Until . . . . . . 164
IN THE SPOTLIGHT: Designing a While Loop . . . . . . . . . . . . . . . . . . . . . . . . . . 169
IN THE SPOTLIGHT: Designing a Do-While Loop . . . . . . . . . . . . . . . . . . . . . . . . 178
five.3 Count-Controlled Loops and the For Statement . . . . . . . . . . . . . . . . . 183
IN THE SPOTLIGHT: Designing a Count-Controlled Loop
with the For Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5.4 Calculating a Running Total . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5.v Sentinels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
IN THE SPOTLIGHT: Using a Watch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
5.6 Nested Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Chapter 6 Functions 217
half-dozen.1 Introduction to Functions: Generating Random Numbers . . . . . . . . . . 217
IN THE SPOTLIGHT: Using Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 221
IN THE SPOTLIGHT: Using Random Numbers to Represent Other Values . . . . . 223
6.2 Writing Your Own Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
IN THE SPOTLIGHT: Modularizing with Functions . . . . . . . . . . . . . . . . . . . . . . . 232
half dozen.3 More Library Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Chapter 7 Input Validation 257
7.1 Garbage In, Garbage Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
7.two The Input Validation Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
IN THE SPOTLIGHT: Designing an Input Validation Loop . . . . . . . . . . . . . . . . . . 260
7.3 Defensive Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Chapter 8 Arrays 269
viii.1 Assortment Nuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
IN THE SPOTLIGHT: Using Assortment Elements in a Math Expression . . . . . . . . . . . 276
viii.2 Sequentially Searching an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
8.3 Processing the Contents of an Assortment . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
IN THE SPOTLIGHT: Processing an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
viii.4 Parallel Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
IN THE SPOTLIGHT: Using Parallel Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
viii.v Ii-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
IN THE SPOTLIGHT: Using a Two-Dimensional Assortment . . . . . . . . . . . . . . . . . . . . 311
8.6 Arrays of 3 or More Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
Chapter 9 Sorting and Searching Arrays 323
ix.1 The Bubble Sort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
IN THE SPOTLIGHT: Using the Bubble Sort Algorithm . . . . . . . . . . . . . . . . . . . . 330
9.2 The Selection Sort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
9.iii The Insertion Sort Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
9.4 The Binary Search Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
IN THE SPOTLIGHT: Using the Binary Search Algorithm . . . . . . . . . . . . . . . . . . . 353
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Affiliate 10 Files 361
10.1 Introduction to File Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . 361
10.2 Using Loops to Procedure Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
IN THE SPOTLIGHT: Working with Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
10.3 Using Files and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
10.4 Processing Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
IN THE SPOTLIGHT: Adding and Displaying Records . . . . . . . . . . . . . . . . . . . . . 388
IN THE SPOTLIGHT: Searching for a Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
IN THE SPOTLIGHT: Modifying Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
IN THE SPOTLIGHT: Deleting Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
x.5 Command Break Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
IN THE SPOTLIGHT: Using Command Pause Logic . . . . . . . . . . . . . . . . . . . . . . . . .403
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Chapter xi Menu-Driven Programs 413
11.1 Introduction to Menu-Driven Programs . . . . . . . . . . . . . . . . . . . . . . . . . 413
eleven.ii Modularizing a Card-Driven Program . . . . . . . . . . . . . . . . . . . . . . . . . 424
eleven.3 Using a Loop to Echo the Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
IN THE SPOTLIGHT: Designing a Carte du jour-Driven Program . . . . . . . . . . . . . . . . . . 434
11.4 Multiple-Level Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Chapter 12 Text Processing 459
12.one Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
12.2 Grapheme-By-Character Text Processing . . . . . . . . . . . . . . . . . . . . . . . . 461
IN THE SPOTLIGHT: Validating a Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
IN THE SPOTLIGHT: Formatting and Unformatting Telephone Numbers . . . . . . 470
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Chapter xiii Recursion 481
xiii.1 Introduction to Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .481
thirteen.2 Trouble Solving with Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .484
13.three Examples of Recursive Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .488
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .498
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .501
Chapter fourteen Object-Oriented Programming 503
fourteen.1 Procedural and Object-Oriented Programming . . . . . . . . . . . . . . . . . . . 503
fourteen.2 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
xiv.iii Using the Unified Modeling Language to Design Classes . . . . . . . . . . . 518
14.4 Finding the Classes and Their Responsibilities in a Problem . . . . . . . . . 521
IN THE SPOTLIGHT: Finding the Classes in a Trouble . . . . . . . . . . . . . . . . . . . . 521
IN THE SPOTLIGHT: Determining Class Responsibilities . . . . . . . . . . . . . . . . . . . 525
14.5 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
xiv.six Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Chapter 15 GUI Applications and Event-Driven Programming 549
xv.1 Graphical User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
xv.ii Designing the User Interface for a GUI Program . . . . . . . . . . . . . . . . . . 552
IN THE SPOTLIGHT: Designing a Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
fifteen.3 Writing Result Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
IN THE SPOTLIGHT: Designing an Event Handler . . . . . . . . . . . . . . . . . . . . . . . . 562
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566

Appendix A ASCII/Unicode Characters 569
Appendix B Flowchart Symbols 570
Appendix C Answers to Checkpoint Questions (located on the CD that accompanies this book)
Index 573


Avez-vous une question à nous poser ?

allenlethed.blogspot.com

Source: https://www.pearson.fr/livre/?gcoi=27440109452450&printBook=1

Postar um comentário for "Programming Logic and Design Chapter 7 Review Questions Answers"