Preface |
|
xxi | |
Acknowledgments |
|
xxix | |
|
Overview of Programming and Problem Solving |
|
|
1 | (46) |
|
|
2 | (7) |
|
|
2 | (1) |
|
|
3 | (6) |
|
Background Information: Mainframes, Micros, and Minis |
|
|
9 | (9) |
|
How Do We Write a Program? |
|
|
13 | (5) |
|
Theoretical Foundations: Data Representation |
|
|
18 | (5) |
|
What Is a Programming Language? |
|
|
19 | (4) |
|
Problem-Solving Techniques |
|
|
23 | (7) |
|
|
25 | (1) |
|
Look for Things That Are Familiar |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
27 | (1) |
|
The Building-Block Approach |
|
|
28 | (1) |
|
|
29 | (1) |
|
|
29 | (1) |
|
Algorithmic Problem Solving |
|
|
30 | (1) |
|
|
30 | (5) |
|
Programming at Many Scales |
|
|
31 | (2) |
|
The Ada Programming Language |
|
|
33 | (2) |
|
Background Information: The Origins of Ada |
|
|
35 | (2) |
|
Problem-Solving Case Study: A Company Payroll |
|
|
37 | (5) |
|
|
42 | (5) |
|
|
43 | (1) |
|
|
44 | (1) |
|
Exam Preparation Exercises |
|
|
44 | (2) |
|
Programming Warm-up Exercises |
|
|
46 | (1) |
|
Ada Syntax, Semantics, and the Program Development Process |
|
|
47 | (70) |
|
The Elements of Ada Programs |
|
|
48 | (5) |
|
|
48 | (3) |
|
|
51 | (2) |
|
Matters of Style: Using Meaningful, Readable Identifiers |
|
|
53 | (1) |
|
|
53 | (1) |
|
Background Information: Data Storage |
|
|
54 | (6) |
|
|
57 | (3) |
|
Software Engineering Tip: Using Constants |
|
|
60 | (12) |
|
|
62 | (6) |
|
Output: Packages and Procedures |
|
|
68 | (3) |
|
|
71 | (1) |
|
Background Information: Ada Lovelace |
|
|
72 | (2) |
|
|
74 | (2) |
|
Program Entry, Correction, and Execution |
|
|
76 | (3) |
|
|
76 | (1) |
|
Compiling and Running a Program |
|
|
77 | (1) |
|
|
78 | (1) |
|
Software Engineering Tip: Understanding Before Changing |
|
|
79 | (1) |
|
|
79 | (5) |
|
|
80 | (3) |
|
|
83 | (1) |
|
|
83 | (1) |
|
Background Information: Strongly Typed Languages |
|
|
84 | (1) |
|
|
85 | (4) |
|
|
85 | (1) |
|
|
86 | (1) |
|
|
87 | (2) |
|
Matters of Style: Program Layout |
|
|
89 | (1) |
|
|
90 | (4) |
|
Problem-Solving Case Study: Mileage |
|
|
94 | (3) |
|
Problem-Solving Case Study: Filling Down Comforters |
|
|
97 | (4) |
|
|
101 | (1) |
|
Testing and Debugging Hints |
|
|
102 | (1) |
|
|
102 | (15) |
|
|
103 | (2) |
|
|
105 | (1) |
|
Exam Preparation Exercises |
|
|
106 | (5) |
|
Programming Warm-up Exercises |
|
|
111 | (3) |
|
|
114 | (3) |
|
Input and Design Methodology |
|
|
117 | (52) |
|
Getting Data into Programs |
|
|
118 | (6) |
|
|
118 | (3) |
|
|
121 | (3) |
|
Theoretical Foundations: More About Procedures and Parameters |
|
|
124 | (19) |
|
|
125 | (4) |
|
Input of Mixed Data Types |
|
|
129 | (9) |
|
|
138 | (5) |
|
Background Information: Charles Babbage |
|
|
143 | (2) |
|
|
145 | (8) |
|
|
145 | (7) |
|
|
152 | (1) |
|
Software Engineering Tip: Documentation |
|
|
153 | (1) |
|
Problem-Solving Case Study: Mixing Proportions |
|
|
154 | (5) |
|
|
159 | (2) |
|
Testing and Debugging Hints |
|
|
160 | (1) |
|
|
161 | (8) |
|
|
162 | (1) |
|
|
162 | (1) |
|
Exam Preparation Exercises |
|
|
162 | (2) |
|
Programming Warm-up Exercises |
|
|
164 | (2) |
|
|
166 | (3) |
|
Boolean and Enumeration Types, Conditions, and Selection Control Structures |
|
|
169 | (62) |
|
Conditions and Boolean Expressions |
|
|
170 | (6) |
|
|
170 | (6) |
|
Background Information: George Boole |
|
|
176 | (2) |
|
|
177 | (1) |
|
Software Engineering Tip: Changing English Statements into Boolean Expressions |
|
|
178 | (1) |
|
|
179 | (1) |
|
|
180 | (1) |
|
|
180 | (4) |
|
|
181 | (2) |
|
|
183 | (1) |
|
|
184 | (5) |
|
|
186 | (3) |
|
|
189 | (5) |
|
|
189 | (3) |
|
Input and Output of Enumeration Types |
|
|
192 | (2) |
|
Problem-Solving Case Study: The Lumberyard |
|
|
194 | (7) |
|
Problem-Solving Case Study: Ski Wax Selection |
|
|
201 | (8) |
|
Temperature Guidelines (used to select a wax group) |
|
|
202 | (7) |
|
|
209 | (10) |
|
The Problem-Solving Phase: The Algorithm Trace |
|
|
209 | (2) |
|
|
211 | (7) |
|
Testing and Debugging Hints |
|
|
218 | (1) |
|
|
219 | (12) |
|
|
219 | (1) |
|
|
220 | (1) |
|
Exam Preparation Exercises |
|
|
220 | (6) |
|
Programming Warm-up Exercises |
|
|
226 | (1) |
|
|
227 | (4) |
|
|
231 | (50) |
|
|
232 | (3) |
|
|
235 | (1) |
|
|
235 | (10) |
|
|
236 | (2) |
|
|
238 | (4) |
|
|
242 | (3) |
|
|
245 | (7) |
|
Designing the Flow of Control |
|
|
246 | (2) |
|
Designing the Process Within the Loop |
|
|
248 | (1) |
|
|
249 | (1) |
|
|
250 | (2) |
|
|
252 | (2) |
|
|
254 | (1) |
|
Theoretical Foundations: The Magnitude of Work |
|
|
254 | (3) |
|
Problem-Solving Case Study: Average Income by Gender |
|
|
257 | (7) |
|
Problem-Solving Case Study: High and Low Temperatures |
|
|
264 | (5) |
|
|
269 | (1) |
|
|
269 | (1) |
|
Testing and Debugging Hints |
|
|
270 | (1) |
|
|
270 | (11) |
|
|
272 | (1) |
|
|
272 | (1) |
|
Exam Preparation Exercises |
|
|
273 | (4) |
|
Programming Warm-up Exercises |
|
|
277 | (1) |
|
|
278 | (3) |
|
|
281 | (96) |
|
Program Design with Procedures |
|
|
282 | (2) |
|
|
282 | (1) |
|
Writing Modules as Procedures |
|
|
283 | (1) |
|
|
284 | (13) |
|
|
286 | (1) |
|
|
286 | (4) |
|
|
290 | (5) |
|
Flow of Control in Procedure Calls |
|
|
295 | (2) |
|
Matters of Style: Naming and Formatting Procedures |
|
|
297 | (1) |
|
|
297 | (4) |
|
|
297 | (1) |
|
Named and Positional Parameter Association |
|
|
298 | (3) |
|
|
301 | (2) |
|
|
303 | (13) |
|
|
304 | (2) |
|
|
306 | (8) |
|
Avoiding Use of Global Variables Through Declaration Order |
|
|
314 | (1) |
|
Designing Programs with Nesting |
|
|
315 | (1) |
|
Overloading Subprogram Names |
|
|
316 | (3) |
|
|
319 | (7) |
|
|
322 | (1) |
|
|
323 | (1) |
|
|
324 | (1) |
|
Standard Mathematical Functions |
|
|
325 | (1) |
|
Problem-Solving Case Study: Running Records |
|
|
326 | (10) |
|
Software Engineering Tip: Control Abstraction, Functional Cohesion, and Communication Complexity |
|
|
336 | (2) |
|
Problem-Solving Case Study: Starship Weight and Balance |
|
|
338 | (13) |
|
|
351 | (5) |
|
|
352 | (3) |
|
Testing and Debugging Hints |
|
|
355 | (1) |
|
|
356 | (21) |
|
|
357 | (1) |
|
|
358 | (1) |
|
Exam Preparation Exercises |
|
|
359 | (10) |
|
Programming Warm-up Exercises |
|
|
369 | (3) |
|
|
372 | (5) |
|
|
377 | (62) |
|
|
378 | (5) |
|
|
379 | (4) |
|
|
383 | (8) |
|
|
384 | (1) |
|
Working with Characters as a Discrete Type |
|
|
385 | (2) |
|
|
387 | (1) |
|
|
387 | (1) |
|
Operations with String and Character Types |
|
|
388 | (3) |
|
Programmer-Defined Scalar Data Types |
|
|
391 | (13) |
|
Floating-Point Type Declarations |
|
|
393 | (4) |
|
Integer Type Declarations |
|
|
397 | (1) |
|
Decimal Type Declarations |
|
|
397 | (3) |
|
|
400 | (1) |
|
Combining Different Types |
|
|
401 | (3) |
|
Theoretical Foundations: Type Coercion and Conversion |
|
|
404 | (1) |
|
|
405 | (6) |
|
Programmer-Defined Subtypes |
|
|
405 | (3) |
|
|
408 | (1) |
|
|
408 | (1) |
|
|
409 | (1) |
|
Input and Output of Subtypes |
|
|
410 | (1) |
|
Named and Anonymous String Types |
|
|
411 | (1) |
|
|
412 | (1) |
|
|
412 | (1) |
|
|
412 | (1) |
|
Software Engineering Tip: Program Portability |
|
|
413 | (1) |
|
|
413 | (2) |
|
|
414 | (1) |
|
Matters of Style: Declarative Part Style |
|
|
415 | (1) |
|
Problem-Solving Case Study: The Rich Uncle |
|
|
415 | (8) |
|
|
415 | (8) |
|
Problem-Solving Case Study: Currency Conversions |
|
|
423 | (7) |
|
|
423 | (7) |
|
|
430 | (1) |
|
Testing and Debugging Hints |
|
|
431 | (1) |
|
|
431 | (8) |
|
|
432 | (1) |
|
|
433 | (1) |
|
Exam Preparation Exercises |
|
|
433 | (2) |
|
Programming Warm-up Exercises |
|
|
435 | (2) |
|
|
437 | (2) |
|
Additional Control Structures |
|
|
439 | (38) |
|
|
440 | (5) |
|
When to Use the Case Statement |
|
|
443 | (1) |
|
|
444 | (1) |
|
|
445 | (6) |
|
|
448 | (1) |
|
|
449 | (2) |
|
Matters of Style: Loop Names |
|
|
451 | (2) |
|
|
452 | (1) |
|
Guidelines for Choosing a Looping Statement |
|
|
453 | (1) |
|
Problem-Solving Case Study: Solitaire Scoring |
|
|
454 | (8) |
|
|
454 | (8) |
|
|
462 | (5) |
|
|
462 | (2) |
|
|
464 | (2) |
|
Testing and Debugging Hints |
|
|
466 | (1) |
|
|
467 | (10) |
|
|
467 | (1) |
|
|
468 | (1) |
|
Exam Preparation Exercises |
|
|
468 | (3) |
|
Programming Warm-up Exercises |
|
|
471 | (2) |
|
|
473 | (4) |
|
The File Data Type and Handling Exceptions |
|
|
477 | (62) |
|
|
478 | (2) |
|
|
479 | (1) |
|
Logical Layout of a Text File |
|
|
|
The End_Of_Line and End_Of_File Functions |
|
|
480 | (5) |
|
Additional Text File Operations |
|
|
485 | (3) |
|
Background Information: Admiral Grace Murray Hopper |
|
|
488 | (9) |
|
|
489 | (8) |
|
|
497 | (13) |
|
Exceptions and Block Statements |
|
|
499 | (5) |
|
Exceptions and Subprograms |
|
|
504 | (1) |
|
Propagation of Exceptions |
|
|
505 | (5) |
|
Matters of Style: Exceptions For Exceptional Situations |
|
|
510 | (2) |
|
|
512 | (3) |
|
Problem-Solving Case Study: The Pasta House |
|
|
515 | (12) |
|
|
527 | (2) |
|
|
529 | (10) |
|
|
529 | (1) |
|
|
530 | (1) |
|
Exam Preparation Exercises |
|
|
530 | (5) |
|
Programming Warm-up Exercises |
|
|
535 | (1) |
|
|
536 | (3) |
|
|
539 | (48) |
|
|
540 | (11) |
|
Operations on Entire Records |
|
|
544 | (4) |
|
|
548 | (1) |
|
|
549 | (2) |
|
|
551 | (2) |
|
|
553 | (6) |
|
Hierarchical Record Aggregates |
|
|
558 | (1) |
|
|
559 | (3) |
|
Style Considerations in Choice of Data Structures |
|
|
559 | (3) |
|
Problem-Solving Case Study: Department Store Accounts |
|
|
562 | (10) |
|
|
572 | (3) |
|
Testing and Debugging Hints |
|
|
575 | (1) |
|
|
575 | (12) |
|
|
575 | (1) |
|
|
576 | (1) |
|
Exam Preparation Exercises |
|
|
577 | (4) |
|
Programming Warm-up Exercises |
|
|
581 | (3) |
|
|
584 | (3) |
|
|
587 | (98) |
|
|
588 | (31) |
|
|
591 | (1) |
|
Accessing Individual Components |
|
|
592 | (1) |
|
Accessing an Entire Array at Once |
|
|
593 | (2) |
|
|
595 | (3) |
|
Examples of Defining and Accessing Arrays |
|
|
598 | (9) |
|
|
607 | (3) |
|
Unconstrained Array Types |
|
|
610 | (7) |
|
|
617 | (2) |
|
|
619 | (17) |
|
Defining and Accessing Two-Dimensional Arrays |
|
|
620 | (4) |
|
Processing Two-Dimensional Arrays |
|
|
624 | (7) |
|
|
631 | (3) |
|
Unconstrained Two-Dimensional Array Types |
|
|
634 | (1) |
|
|
635 | (1) |
|
|
636 | (3) |
|
Software Engineering Tip: Choosing a Data Structure |
|
|
639 | (1) |
|
Problem-Solving Case Study: Frequency of Characters |
|
|
640 | (6) |
|
Problem-Solving Case Study: Mustard Yields |
|
|
646 | (4) |
|
Problem-Solving Case Study: City Council Election |
|
|
650 | (8) |
|
|
658 | (2) |
|
Testing and Debugging Hints |
|
|
660 | (1) |
|
|
660 | (25) |
|
|
661 | (2) |
|
|
663 | (2) |
|
Exam Preparation Exercises |
|
|
665 | (9) |
|
Programming Warm-up Exercises |
|
|
674 | (3) |
|
|
677 | (8) |
|
Packages, Searching, and Sorting |
|
|
685 | (84) |
|
|
686 | (4) |
|
|
688 | (1) |
|
|
689 | (1) |
|
|
690 | (9) |
|
|
690 | (2) |
|
|
692 | (5) |
|
Data Abstraction Packages |
|
|
697 | (2) |
|
Compilation of Programs and Packages |
|
|
699 | (6) |
|
|
700 | (1) |
|
|
701 | (4) |
|
Background Information: Reusable Components and Software Repositories |
|
|
705 | (1) |
|
|
706 | (5) |
|
|
707 | (1) |
|
|
708 | (3) |
|
The Predefined Package Standard |
|
|
711 | (1) |
|
|
712 | (20) |
|
Sequential Search in an Unordered List |
|
|
713 | (5) |
|
|
718 | (4) |
|
Sequential Search in an Ordered List |
|
|
722 | (2) |
|
Inserting into an Ordered List |
|
|
724 | (2) |
|
|
726 | (2) |
|
Binary Search in an Ordered List |
|
|
728 | (4) |
|
Theoretical Foundations: Complexity of Searching and Sorting |
|
|
732 | (7) |
|
|
734 | (5) |
|
Problem-Solving Case Study: A Data Abstraction Package for Vectors |
|
|
739 | (6) |
|
Problem-Solving Case Study: Exam Attendance |
|
|
745 | (11) |
|
|
756 | (2) |
|
Testing and Debugging Hints |
|
|
758 | (1) |
|
|
758 | (11) |
|
|
759 | (2) |
|
|
761 | (1) |
|
Exam Preparation Exercises |
|
|
761 | (3) |
|
Programming Warm-up Exercises |
|
|
764 | (1) |
|
|
764 | (5) |
|
|
769 | |
|
|
770 | (7) |
|
Recursive Algorithms with Simple Variables |
|
|
777 | (12) |
|
|
779 | (4) |
|
|
783 | (6) |
|
Recursive Algorithms with Array Variables |
|
|
789 | (6) |
|
|
792 | (1) |
|
|
793 | (2) |
|
|
795 | (1) |
|
Problem-Solving Case Study: Converting Decimal Integers to Binary Integers |
|
|
796 | (4) |
|
Problem-Solving Case Study: Minimum Value in an Integer Array |
|
|
800 | (2) |
|
|
802 | (1) |
|
Testing and Debugging Hints |
|
|
802 | (1) |
|
|
803 | |
|
|
803 | (1) |
|
|
804 | (1) |
|
Exam Preparation Exercises |
|
|
804 | (3) |
|
Programming Warm-up Exercises |
|
|
807 | (3) |
|
|
810 | |
Appendices |
|
A1 | |
Glossary |
|
A59 | |
Answers to Selected Exercises |
|
A75 | |
Index |
|
A95 | |