Programming Logic & Design, Comprehensive 9th edition Joyce Farrell - eBook PDF instant download
Programming Logic & Design, Comprehensive 9th edition Joyce Farrell - eBook PDF instant download
https://ebooksecure.com/download/programming-logic-design-
comprehensive-9th-edition-ebook-pdf/
https://ebooksecure.com/download/programming-logic-and-design-
comprehensive-9th-edition-ebook-pdf/
https://ebooksecure.com/download/java-programming-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-programming-logic-
design-comprehensive-9th-edition/
https://ebooksecure.com/download/java-programming-mindtap-course-
list-10th-edition-ebook-pdf/
(eBook PDF) Starting Out with Programming Logic and
Design 4th
http://ebooksecure.com/product/ebook-pdf-starting-out-with-
programming-logic-and-design-4th/
https://ebooksecure.com/download/starting-out-with-programming-
logic-and-design-6e-ebook-pdf/
https://ebooksecure.com/download/biochemistry-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-digital-logic-circuit-
analysis-and-design-2nd-edition/
https://ebooksecure.com/download/introduction-to-java-
programming-comprehensive-version-ebook-pdf/
Joyce Farrell
COMPREHENSIVE
Programming
Logic & Design
Ninth Edition
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Buy. Rent. Access.
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
PROGRAMMING LOGIC
AND DESIGN
COMPREHENSIVE
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
NINTH EDITION
PROGRAMMING LOGIC
AND DESIGN
COMPREHENSIVE
JOYCE FARRELL
Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Programming Logic and Design, © 2018 Cengage Learning®
Comprehensive
ALL RIGHTS RESERVED. No part of this work covered by the
Ninth Edition
copyright herein may be reproduced or distributed in any form
Joyce Farrell
or by any means, except as permitted by U.S. copyright law,
Senior Product Director: without the prior written permission of the copyright owner.
Kathleen McMahon
For product information and technology assistance, contact us at
Product Team Leader: Kristin McNary
Cengage Learning Customer & Sales Support, 1-800-354-9706
Associate Product Manager: Kate Mason
For permission to use material from this text or product,
Senior Content Developer: Alyssa Pratt submit all requests online at www.cengage.com/permissions
Senior Content Project Manager: Further permissions questions can be emailed to
permissionrequest@cengage.com
Jennifer Feltri-George
Manufacturing Planner: Julio Esperas
Art Director: Diana Graham Library of Congress Control Number: 2016959742
Production Service/Composition: ISBN: 978-1-337-10207-0
SPi Global
Cover Photo: Cengage Learning
Colormos/Photodisc/Getty Images 20 Channel Center Street
Boston, MA 02210
USA
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Brief Contents
v
Pref ace ������� ��� �� ��� ��� ��� ���� �� ��� ��� ��� ������ ��� ��� xvi
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Contents
vii
Pref ace ������� ��� �� ��� ��� ��� ���� �� ��� ��� ��� ������ ��� ��� xvi
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CONTENTS
CHAPTER 3 U n der s t an din g Structure ����� � ����� ��� ��� ��� ���� ��� 87
The Disadvantages of Unstructured Spaghetti Code��������������88
Understanding the Three Basic Structures ��������������������������90
The Sequence Structure ������������������������������������������������90
The Selection Structure��������������������������������������������������91
The Loop Structure ������������������������������������������������������92
Combining Structures ���������������������������������������������������93
Using a Priming Input to Structure a Program�����������������������99
Understanding the Reasons for Structure��������������������������� 106
Recognizing Structure���������������������������������������������������� 107
Structuring and Modularizing Unstructured Logic ��������������� 110
Chapter Summary ��������������������������������������������������������� 115
Key Terms��������������������������������������������������������������������� 115
Exercises ��������������������������������������������������������������������� 117
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CONTENTS
CHAPTER 4 M ak in g Decis ions ������ ��� ��� ��� � ����� ��� ��� ��� ���� � 124
The Selection Structure�������������������������������������������������� 125
Using Relational Comparison Operators ���������������������������� 129
Avoiding a Common Error with Relational Operators��������� 133
Understanding AND Logic������������������������������������������������ 134 ix
Nesting AND Decisions for Efficiency ���������������������������� 137
Using the AND Operator ���������������������������������������������� 139
Avoiding Common Errors in an AND Selection������������������ 141
Understanding OR Logic ������������������������������������������������� 143
Writing OR Selections for Efficiency ������������������������������ 145
Using the OR Operator ������������������������������������������������ 147
Avoiding Common Errors in an OR Selection������������������� 147
Understanding NOT Logic������������������������������������������������ 153
Avoiding a Common Error in a NOT Expression ��������������� 154
Making Selections within Ranges ������������������������������������� 155
Avoiding Common Errors When Using Range Checks ������� 157
Understanding Precedence When Combining
AND and OR Operators��������������������������������������������������� 160
Understanding the case Structure ���������������������������������� 163
Chapter Summary ��������������������������������������������������������� 165
Key Terms��������������������������������������������������������������������� 166
Exercises ��������������������������������������������������������������������� 167
CHAPTER 5 Lo o pin g ������ � �� ��� ������ ��� ��� ��� � ����� ��� ��� ��� ���� � 176
Appreciating the Advantages of Looping ��������������������������� 177
Using a Loop Control Variable������������������������������������������ 179
Using a Definite Loop with a Counter������������������������������ 179
Using an Indefinite Loop with a Sentinel Value ���������������� 181
Understanding the Loop in a Program’s Mainline Logic������ 183
Nested Loops ��������������������������������������������������������������� 185
Avoiding Common Loop Mistakes ������������������������������������ 190
Mistake: Failing to Initialize the Loop Control Variable ������ 190
Mistake: Neglecting to Alter the Loop Control Variable������ 191
Mistake: Using the Wrong Type of Comparison When
Testing the Loop Control Variable ������������������������������� 192
Mistake: Including Statements Inside the Loop Body
that Belong Outside the Loop ������������������������������������� 194
Using a for Loop ���������������������������������������������������������� 199
Using a Posttest Loop ��������������������������������������������������� 201
Recognizing the Characteristics Shared
by Structured Loops ���������������������������������������������������� 203
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CONTENTS
CHAPTER 6 Ar r ays �� ������ ��� ��� ������ ��� ��� ��� � ����� ��� ��� ��� ���� � 227
Storing Data in Arrays���������������������������������������������������� 228
How Arrays Occupy Computer Memory��������������������������� 228
How an Array Can Replace Nested Decisions��������������������� 231
Using Constants with Arrays ������������������������������������������� 238
Using a Constant as the Size of an Array������������������������ 238
Using Constants as Array Element Values ���������������������� 239
Using a Constant as an Array Subscript ������������������������� 239
Searching an Array for an Exact Match������������������������������ 240
Using Parallel Arrays������������������������������������������������������ 244
Improving Search Efficiency������������������������������������������ 248
Searching an Array for a Range Match������������������������������ 250
Remaining within Array Bounds���������������������������������������� 255
Understanding Array Size��������������������������������������������� 255
Understanding Subscript Bounds ���������������������������������� 255
Using a for Loop to Process an Array������������������������������ 258
Chapter Summary ��������������������������������������������������������� 260
Key Terms��������������������������������������������������������������������� 261
Exercises ��������������������������������������������������������������������� 261
CHAPTER 7 F ile Han dlin g and Appl i cati ons����� ��� ��� ��� ���� � 272
Understanding Computer Files ���������������������������������������� 273
Organizing Files ��������������������������������������������������������� 274
Understanding the Data Hierarchy������������������������������������ 275
Performing File Operations ��������������������������������������������� 277
Declaring a File Identifier��������������������������������������������� 277
Opening a File������������������������������������������������������������ 278
Reading Data from a File and Processing It��������������������� 278
Writing Data to a File��������������������������������������������������� 281
Closing a File������������������������������������������������������������� 281
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CONTENTS
CHAPTER 9 Advan ced M o dul ari z ati on Techni ques ����� ���� � 366
The Parts of a Method ��������������������������������������������������� 367
Using Methods with no Parameters ���������������������������������� 368
Creating Methods that Require Parameters������������������������ 371
Creating Methods that Require Multiple Parameters ��������� 377
Creating Methods that Return a Value������������������������������� 379
Using an IPO Chart������������������������������������������������������ 384
Passing an Array to a Method������������������������������������������ 386
Overloading Methods������������������������������������������������������ 394
Avoiding Ambiguous Methods ��������������������������������������� 397
Using Predefined Methods ���������������������������������������������� 400
Method Design Issues: Implementation Hiding, Cohesion,
and Coupling��������������������������������������������������������������� 402
Understanding Implementation Hiding ���������������������������� 402
Increasing Cohesion ��������������������������������������������������� 403
Reducing Coupling������������������������������������������������������ 404
Understanding Recursion������������������������������������������������ 405
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CONTENTS
CHAPTER 10 Object -Or ien t ed Programmi ng ����� ��� ������ ��� �� 420
xii
Principles of Object-Oriented Programming������������������������ 421
Classes and Objects ��������������������������������������������������� 421
Polymorphism ������������������������������������������������������������ 424
Inheritance ���������������������������������������������������������������� 426
Encapsulation ������������������������������������������������������������ 426
Defining Classes and Creating Class Diagrams ������������������ 428
Creating Class Diagrams ��������������������������������������������� 430
The Set Methods��������������������������������������������������������� 433
The Get Methods��������������������������������������������������������� 434
Work Methods������������������������������������������������������������ 435
Understanding Public and Private Access��������������������������� 437
Organizing Classes��������������������������������������������������������� 440
Understanding Instance Methods ������������������������������������� 441
Understanding Static Methods������������������������������������������ 447
Using Objects ��������������������������������������������������������������� 448
Passing an Object to a Method ������������������������������������� 449
Returning an Object from a Method ������������������������������� 450
Using Arrays of Objects ���������������������������������������������� 453
Chapter Summary ��������������������������������������������������������� 455
Key Terms��������������������������������������������������������������������� 456
Exercises ��������������������������������������������������������������������� 458
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CONTENTS
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CONTENTS
APPENDIX B So lvin g Dif f icu l t Structuri ng Probl ems ��� ��� �� 547
xiv
Glo s s ar y ��� ��� ��� �� ��� ��� ��� ��� ��� ��� ��� ��� ���� �� ��� �� 556
In dex������ �� ��� ���� ��� �� ��� ��� ��� ���� �� ��� ��� ��� ������ �� 571
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Preface
xvi
Programming Logic and Design, Comprehensive, Ninth Edition, provides the beginning
programmer with a guide to developing structured program logic. This textbook assumes
no programming language experience. The writing is nontechnical and emphasizes
good programming practices. The examples are business examples; they do not assume
mathematical background beyond high school business math.
Additionally, the examples illustrate one or two major points; they do not contain so
many features that students become lost following irrelevant and extraneous details. The
examples in this book have been created to provide students with a sound background in
logic, no matter what programming languages they eventually use to write programs. This
book can be used in a stand-alone logic course that students take as a prerequisite to a
programming course, or as a companion book to an introductory programming text using
any programming language.
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Organization and Coverage P R E FA C E
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Features
This text focuses on helping students become better programmers, as well as helping them
understand the big picture in program development through a variety of features. Each
chapter begins with objectives and ends with a list of key terms and a summary; these
xviii useful features will help students organize their learning experience.
Don’t Do It
FLOWCHARTS, figures, This logic is structured,
but flawed. When the user
and illustrations provide start
inputs the eof value, it will
tested. Instead, a result is calculated and displayed one last time before the loop-controlling
test is made again. If the program was written to recognize eof when originalNumber is 0,
then an extraneous answer of 0 will be displayed before the program ends. Depending on
the language you are using and on the type of input being used, the results might be worse:
The program might terminate by displaying an error message or the value output might
be indecipherable garbage. In any case, this last output is superfluous—no value should be
doubled and output after the eof condition is encountered.
As a general rule, a program-ending test should always come immediately after an input
statement because that’s the earliest point at which it can be evaluated. Therefore, the best
solution to the number-doubling problem remains the one shown in Figure 3-16—the
structured solution containing the priming input statement.
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
F E AT U R E S
Computer memory consists of millions of numbered locations where data can be stored. The memory
location of myNumber has a specific numeric address, but when you write programs, you seldom need
to be concerned with the value of the memory address; instead, you use the easy-to-remember name
you created. Computer programmers often refer to memory addresses using hexadecimal notation,
or base 16. Using this system, they might use a value like 42FF01A to refer to a memory address.
Despite the use of letters, such an address is still a number. Appendix A contains information about the
hexadecimal numbering system.
1. NOTES provide
A program with syntax errors can execute but might produce incorrect
results.
additional information—
2. Although the syntax of programming languages differs, the same program
logic can be expressed in different languages. for example, another
3. Most simple computer programs include steps that location
perform input,in the book that
processing, and output.
expands on a topic, or a
common error to avoid.
a program with no syntax errors can execute, but might produce incorrect results.
The false statement is #1. A program with syntax errors cannot execute;
Exercises
Review Questions
32
1. Computer programs also are known as ____________.
a. data c. software
b. hardware d. information
2. The major computer operations include ____________.
a. input, processing, and output
b. hardware and software
c. sequence and looping
d. CHAPTER 4
spreadsheets, word processing, and data communications Making Decisions
3. Visual Basic, C++, and Java are all examples of computer ____________.
a. operating systems c. hardware
b. programming languages Programming
d. machine languages Exercises
4. A programming language’s rules are its ____________. 1. Assume that the following variables contain the values shown:
a. syntax c.170format numberBig = 100 wordBig = "Constitution"
b. logic d. options numberMedium = 10 wordMedium = "Dance"
numberSmall = 1 wordSmall = "Toy”
5. The most important task of a compiler or interpreter is to ____________.
For each of the following Boolean expressions, decide whether the statement is
a. create the rules for a programming language true, false, or illegal.
b. translate English statements into a language such as Java a. numberBig > numberSmall
c. translate programming language statements into machine languageb. numberBig < numberMedium
d. execute machine language programs to perform useful tasks c. numberMedium = numberSmall
6. Which of the following is temporary, internal storage? d. numberBig = wordBig
a. CPU c. keyboard e. numberBig = "Big"
3. Design a flowchart or pseudocode for a program that accepts three numbers from
a user and displays a message if the sum of any two numbers equals the third.
PERFORMING MAINTENANCE
Exercises
exercises ask students to modify
working logic based on new
c. Modify the softball program so that it also computes a gross production
requested specifications.
average (GPA) for each player.This
A GPA is calculated by multiplying a player’s
on-base percentage by 1.8, then adding the player’s slugging percentage, and xxi
activity then
mirrors real-world
dividing by four. tasks
that
10. students arechart
Draw the hierarchy likelyand to
design the logic for a program for Arnie’s 85
encounter in their first programming
Appliances. Design a program that prompts the user for a refrigerator model
name and the interior height, width, and depth in inches. Calculate the
jobs.refrigerator capacity in cubic feet by first multiplying the height, width, and
depth to get cubic inches, and then dividing by 1728 (the number of cubic inches
in a cubic foot). The program accepts model names continuously until “XXX” is
entered. Use named constants where appropriate. Also use modules, including
one that displays End of job after the sentinel is entered for the model name.
Performing Maintenance
1. A file named MAINTENANCE02-01.txt is included with your downloadable
student files. Assume that this program is a working program in your
organization and that it needs modifications as described in the comments (lines
that begin with two slashes) at the beginning of the file. Your job is to alter the
program to meet the new specifications.
2. Your downloadable files for Chapter 2 include a file named DEBUG02-04.jpg that
contains a flowchart with syntax and/or logical errors. Examine the flowchart,
and then find and correct all the bugs.
Game Zone
1. For games to hold your interest, they almost always include some random,
unpredictable behavior. For example, a game in which you shoot asteroids loses
some of its fun if the asteroids follow the same, predictable path each time you
play. Therefore, generating random values is a key component in creating most
MindTap
MindTap is a personalized learning experience with relevant assignments that guide stu-
dents in analyzing problems, applying what they have learned, and improving their think-
ing. MindTap allows instructors to measure skills and outcomes with ease.
For instructors: Personalized teaching becomes yours with a learning path that is built with
key student objectives. You can control what students see and when they see it. You can use
MindTap as-is, or match it to your syllabus by hiding, rearranging, or adding content.
For students: A unique learning path of relevant readings, multimedia, and activities is cre-
ated to guide you through basic knowledge and comprehension of analysis and application.
For both: Better outcomes empower instructors and motivate students with analytics and
reports that provide a snapshot of class progress, the time spent in the course, engagement
levels, and completion rates.
The MindTap for Programming Logic and Design includes coding labs in C11, Java, and
Python, study tools, videos, and interactive quizzing, all integrated into an eReader that
includes the full content of the printed text.
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Acknowledgments P R E FA C E
Instructor Resources
The following teaching tools are available to the instructor for download through our
Instructor Companion Site at sso.cengage.com.
•• Instructor’s Manual. The Instructor’s Manual follows the text chapter by chapter to
xxiii
assist in planning and organizing an effective, engaging course. The manual includes
learning objectives, chapter overviews, lecture notes, ideas for classroom activities, and
abundant additional resources. A sample course syllabus is also available.
•• PowerPoint Presentations. This text provides PowerPoint slides to accompany each
chapter. Slides are included to guide classroom presentations, and can be made available
to students for chapter review, or to print as classroom handouts.
•• Solutions. Solutions to review questions and exercises are provided to assist with grading.
•• Test Bank®. Cengage Learning Testing Powered by Cognero is a flexible, online system
that allows you to:
•• author, edit, and manage test bank content from multiple Cengage Learning
solutions,
•• create multiple test versions in an instant, and
•• deliver tests from your LMS, your classroom, or anywhere you want.
Additional Options
•• Visual Logic™ software. Visual Logic is a simple but powerful tool for teaching
rogramming logic and design without traditional high-level programming language
p
syntax. Visual Logic also interprets and executes flowcharts, providing students with
immediate and accurate feedback.
Acknowledgments
I would like to thank all of the people who helped to make this book a reality, especially
Alyssa Pratt, Jennifer Feltri-George, Kristin McNary, Kate Mason, and all the other
professionals at Cengage Learning who made this book possible. Thanks, too, to my
husband, Geoff, and our daughters, Andrea and Audrey, for their support. This book, as
were all its previous editions, is dedicated to them.
–Joyce Farrell
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CHAPTER 1
An Overview
of Computers
and Programming
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CHAPTER 1 An Overview of Computers and Programming
•• Output: After data items have been processed, the resulting information usually is sent
to a printer, monitor, or some other output device so people can view, interpret, and use
the results. Programming professionals often use the term data for input items, but use
the term information for data items that have been processed and output. Sometimes
you place output on storage devices, such as your hard drive, flash media, or a
cloud-based device. (The cloud refers to devices at remote locations accessed through 3
the Internet.) People cannot read data directly from these storage devices, but the
devices hold information for later retrieval. When you send output to a storage device,
sometimes it is used later as input for another program.
You write computer instructions in a computer programming language such as Visual Basic,
C#, C++, or Java. Just as some people speak English and others speak Japanese, programmers
write programs in different languages. Some programmers work exclusively in one language,
whereas others know several and use the one that is best suited to the task at hand.
The instructions you write using a programming language are called program code; when
you write instructions, you are coding the program.
Every programming language has rules governing its word usage and punctuation. These
rules are called the language’s syntax. Mistakes in a language’s usage are syntax errors. If
you ask, “How the geet too store do I?” in English, most people can figure out what you
probably mean, even though you have not used proper English syntax—you have mixed up
the word order, misspelled a word, and used an incorrect word. However, computers are
not nearly as smart as most people; in this case, you might as well have asked the computer,
“Xpu mxv ort dod nmcad bf B?” Unless the syntax is perfect, the computer cannot interpret
the programming language instruction at all.
Figure 1-1 shows how the statement that displays the word Hello on a single line on a
computer monitor looks in some common programming languages. Notice that the syntax
of some languages require that a statement start with an uppercase letter, while the syntax
of others does not. Notice that some languages end statements with a semicolon, some with
a period, and some with no ending punctuation at all. Also notice that different verbs are
used to mean display, and that some are spelled like their like English word counterparts,
while others like cout and System.out.println are not regular English words. The different
formats you see are just a hint of the various syntaxes used by languages.
Figure 1-1 Displaying the word Hello in some common programming languages
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
CHAPTER 1 An Overview of Computers and Programming
After you learn French, you automatically know, or can easily figure out, many Spanish words. Similarly,
after you learn one programming language, it is much easier to understand other languages.
4 When you write a program, you usually type its instructions using a keyboard. When you
type program instructions, they are stored in computer memory, which is a computer’s
temporary, internal storage. Random access memory, or RAM, is a form of internal,
volatile memory. Programs that are running and data items that are being used are stored in
RAM for quick access. Internal storage is volatile—its contents are lost when the computer
is turned off or loses power. Usually, you want to be able to retrieve and perhaps modify
the stored instructions later, so you also store them on a permanent storage device, such
as a disk. Permanent storage devices are nonvolatile—that is, their contents are persistent
and are retained even when power is lost. If you have had a power loss while working on
a computer, but were able to recover your work when power was restored, it’s not because
the work was still in RAM. Your system has been configured to automatically save your
work at regular intervals on a nonvolatile storage device—often your hard drive.
After a computer program is typed using programming language statements and stored
in memory, it must be translated to machine language that represents the millions of on/
off circuits within the computer. Your programming language statements are called source
code, and the translated machine language statements are object code.
Each programming language uses a piece of software, called a compiler or an interpreter,
to translate your source code into machine language. Machine language also is called
binary language, and is represented as a series of 0s and 1s. The compiler or interpreter
that translates your code tells you if any programming language component has been used
incorrectly. Syntax errors are relatively easy to locate and correct because your compiler or
interpreter highlights them. If you write a computer program using a language such as C++,
but spell one of its words incorrectly or reverse the proper order of two words, the software
lets you know that it found a mistake by displaying an error message as soon as you try to
translate the program.
Although there are differences in how compilers and interpreters work, their basic function is the
same—to translate your programming statements into code the computer can use. When you use
a compiler, an entire program is translated before it can execute; when you use an interpreter, each
instruction is translated just prior to execution. Usually, you do not choose which type of translation to
use—it depends on the programming language. However, some languages can use both compilers and
interpreters.
After a program’s source code is translated successfully to machine language, the computer
can carry out the program instructions. When instructions are carried out, a program runs,
or executes. In a typical program, some input will be accepted, some processing will occur,
and results will be output.
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300
Another Random Scribd Document
with Unrelated Content
[Illustration: RAISING HIS VOICE HE SHOUTED, "LET GO!"]
Now he was putting his faith to the acid test. Woodleigh was in
sole control of the helm. If he failed to carry out his instructions or
misinterpreted the reading of the chart, then goodness only knows
what might happen.
Up through the South-West Reach, across the shoals into the East
Swin, the Olivette made her way.
The new course, approximately N.N.W., was now dead in the eye of
the wind, and Woodleigh began to experience some of the
discomforts his Scoutmaster had endured during the night. Now it
was broad daylight, and the white-crested masses of water bearing
down upon the boat looked very threatening.
Mr. Armitage was still sleeping soundly. Even the racket in the
Wallet failed to rouse him; but Stratton, shaking off his lethargy,
climbed into the wheel-house and stood behind the helmsman.
"I'll wait till we're in," he decided. "Not much fun stocking an
anchor with the boat jumping about like this. I say, bit of crowd, isn't
it?"
He pointed ahead, where the estuary of the Colne was black with
the hulls of fishing-smacks that had run in on the approach of bad
weather.
Within the last ten minutes the wind had shifted from N.N.W. to
S.E., and in consequence Mersea Flats, on the port hand to the
entrance of the river, were a lee shore. Above the noise of the
engine the two Scouts could hear the roar of the breakers upon the
hard sand, for it was now just on low water.
The clearing away of the heavy anchor, and the securing of the
forelock, was not accomplished in a moment, and, by the time all
was in readiness for letting go, Woodleigh had "opened out" the little
town of Brightlingsea, standing on the northern bank of the creek
that derives its name from the busy yachting and fishing centre.
The roar of the cable through the fair-leads announced that the
voyage of the Olivette, as far as the Milford Sea Scouts were
concerned, was an accomplished fact. It also had the effect of
rousing the Scoutmaster from his slumbers.
The crew, having been "given the tip", watched the expression on
Mr. Armitage's face with ill-concealed amusement.
CHAPTER XI
The "Rosalie"
For some moments Mr. Armitage hardly knew what to say. When
his first feelings of astonishment subsided, he felt inclined to
reprimand Woodleigh for disobeying orders. Had the lad made a
blunder the consequences might have been serious—but he hadn't.
"After all," thought the Scoutmaster, "he did very well. Sort of
Nelson touch about that lad. If he acted with deliberate judgment,
and not through a sheer slice of luck, he's cut out for navigating
duties. 'Tany rate, I've had a good sound sleep, but I wouldn't have
slumbered so quietly had I known."
"We thought we'd wait till the ebb makes before we run out a
kedge, sir," reported the Patrol-leader; "then she'll ride to her main
anchor and cable."
"Quite right," agreed Mr. Armitage. "What's the time? Eight o'clock.
Any breakfast going?"
There was. From the galley came the first appetizing smell of
grilling bacon. Warkworth, who revelled in the work in the galley,
was preparing a substantial meal, supplemented by coffee.
"You ought to have turned me out when you sighted the Maplin,"
continued the Scoutmaster.
"And a jolly little spot it is!" declared the owner. "Who's ready for
breakfast? I'm as hungry as a hunter."
It was a jovial party that gathered round the long, folding table. In
spite of the strenuous passage and the lack of an uninterrupted
night's rest, the Sea Scouts were in high spirits. They realized that
the Olivette had fought a battle with the elements, and that she had
emerged triumphantly out of the ordeal.
"You'll be all right here with a crew who know this part of the
coast," observed Mr. Armitage.
"Rather!" agreed Mr. Murgatroyd. "I wish, though, that some of you
lads could remain, but I know that's out of the question. What are
your plans?"
"Why not remain here until to-morrow?" asked the owner of the
Olivette.
"I'll try to follow your example," he said, "and make some sort of a
sailor-man. It's never too late to learn, as I expect I've said before."
"Decent old chap," remarked Peter Stratton, when the Sea Scouts
embarked in a ferry-boat and were taken ashore. "Wonder if the
owner of the Rosalie is anything like him?"
"We won't know until we hand the yacht over," replied the
Scoutmaster. "He's not coming with us. That reminds me, I must
send a wire to our friend the Oxford Scoutmaster."
"Yes," was the reply. "You fellows are doing so well, that I feel out
of it; so, needing someone to keep me company, I invited Mr.
Jackson for the voyage from Yarmouth to Poole. He and I will have a
rare, good, lazy time, sitting on deck and watching you do the
donkey-work."
"I can see you doing that, sir," rejoined Hepburn, laughing.
"Wonder what the Rosalie is like?"
"Possess your soul in patience for another six hours, Alan, and your
curiosity will, I hope, be satisfied," replied Mr. Armitage.
"I know a better plan," replied the Patrol-leader. "I'll buy picture
post cards for Woodleigh and you, and you can post them on the
way to the railway station."
'Tween decks things were more hopeful. Although there was dirt
and dust everywhere, everything was fairly dry.
Right aft, and gained by a companion-ladder from a very small
cockpit, was the main cabin, fitted throughout in teak, and
possessing four sofa berths. In the centre was a large table, while
there was more than 6 feet 6 inches headroom under the deck-
beams. Through the for'ard bulkhead of the saloon were two
doorways, one leading to a small, compact, and well-fitted galley,
the other to a single-berthed sleeping-cabin.
"We've got our work cut out to get shipshape before night,"
declared Mr. Armitage briskly. "All hands to it, and we'll soon break
the back of the job."
The Sea Scouts were told off to their respective tasks. Stratton and
Hepburn tackled the work of scrubbing decks, airing sails, and
overhauling the running-gear. Roche and Flemming took on the
motor-room, running the engines, testing the controls, and seeing
"how things worked", in addition to gauging the contents of the
petrol and oil tanks, and "checking" the engineers' stores.
Woodleigh and Warkworth cleaned out the forepeak and the galley,
while the Scoutmaster toiled like a Trojan in the main cabin.
"It may not be too rough for the yacht," replied Mr. Armitage, "but
it may be too rough for us. Remember it's the human element that
counts. We don't know the Rosalie. She, no doubt, has her
peculiarities, which her former crew understood. We don't. We have
to find them out. See what I mean?"
The wire was from Mr. Jackson to say that he was leaving Liverpool
Street at eight.
"He'll be here just after twelve," said the Scoutmaster. "It's now
twenty past eleven, so Warkworth and Hepburn can go to the station
to meet him and bring him along. By Jove! It's piping up. We'll be
lucky if we are able to start to-morrow."
CHAPTER XII
The Squall
"And the danger still exists," he continued. "I haven't said anything
to my youngsters, because I didn't consider it advisable. But the fact
remains that there are stray floating mines that can hardly be seen
owing to their being smothered with barnacles and weeds. And
they'll be knocking around for years, I'm afraid."
Mr. Armitage glanced aloft. In the twilight the dark clouds were not
scudding so rapidly as they had done earlier in the day.
At 5 a.m. all hands turned out, bathed, and had breakfast. It was
still blowing fairly fresh, but the wind had veered through west and
was now practically nor'-west.
"Off-shore wind," observed the Scoutmaster. "We'll be all right as
far as Harwich, so get busy."
Precisely at eight o'clock the Red Ensign was hoisted, the warps
cast off, and the yacht, under power, started on her long voyage.
By the time she had taken to traverse the long stretch of river that
enters the North Sea at Gorleston, Peter Stratton had made himself
acquainted with Rosalie's steering capabilities, in spite of the fact
that navigation was rather complicated owing to the number of
fishing-boats under way in the narrow channel.
"Look out for the tide setting across the pierheads," cautioned the
Scoutmaster.
The North Sea was not looking at its best. Although the wind was
off shore, there was a nasty "lop" off the entrance to the harbour.
Even the lightship was pounding heavily, cascades of water pouring
through her hawse-pipes as she lifted to the waves; sailing-coasters
were rolling badly in spite of their reduced canvas; and tramps, with
trysails set to steady them, were lurching along, leaving a long,
almost horizontal trail of smoke far to leeward.
"Thick out there," observed Hepburn. "As bad as we had round the
Maplins. We're rolling a bit too."
There was no doubt about it, the Rosalie could and did roll. With
the wind abeam her decks were soon wet. It was almost impossible
for the crew to move without holding on, and, except for the small
wheel-house, there was no protection on deck from the wind and
spray.
"We'll see what a little canvas will do," said Mr. Armitage. "She's
stiff enough. Up with trysail and mainsail, lads."
"A good ten or eleven knots," declared Mr. Armitage. "She's as stiff
as a house. We'll have the foresail set and stop the engines."
This was done. Although the speed fell off to a bare five knots, the
yacht was carrying her tide and simply waltzing past the shore.
"Give me sail for pleasure any old day," declared Mr. Jackson.
"Petrol's all very well if you're in a hurry, but when all's said and
done canvas wants a lot of beating."
The Sea Scouts revelled in the situation. With the breeze being true
and in their favour, they could lie on the deck and enjoy the view, as
the Rosalie slipped past Lowestoft and made short work of it
towards Southwold. Close in under the land they were no longer
subjected to clouds of spray, and the tardy appearance of the sun
gave a finishing touch to their enjoyment.
So the Rosalie held on, passing close to Aldborough, and giving the
low-lying Orfordness a wide berth, and at 5 p.m., without having had
to touch a single sheet from the time canvas had been set, Hepburn
reported a lightship on the port bow.
"We'll leave you to it, Alan," he said. "If you want anything, give a
hail. We'll keep your tea hot."
The rest of the crew went below, where a sumptuous meal was
being served in the main cabin, leaving Hepburn in the wheel-house.
Not a little scared, the rest of the crew lowered and secured the
mainsail, while the Rosalie, under bare poles, fell broadside on to the
waves, which in a very short time had assumed huge and
threatening proportions. It was an off-shore squall, and none the
less dangerous on that account, and until Roche and Flemming got
the motors going the Rosalie had a particularly bad time.
It was raining heavily. Already the shore, although less than two
miles away, was blotted out. The wind shrieked through the rigging,
blinding showers of spray enveloped the wheel-house, and solid
masses of water pounded the heaving, slippery deck.
In ten minutes the squall was over. The sun shone brightly, and
although the waves ran high they were no longer dangerous, while
dead to windward lay the secure harbour of Harwich.
"Why didn't you luff when you saw it coming, Alan?" asked Mr.
Armitage.
In the galley things were almost as bad, but the fo'c'sle came off
lightly. That was mainly owing to the methodical stowing of gear by
the lads themselves, and the few kit-bags that had been dislodged
were quickly replaced.
"We were not the only craft in that squall, sir," reported Stratton.
"There's a tug coming in with two dismasted boats."
The two Scoutmasters and the rest of the Sea Scouts hurried on
deck. Passing the entrance to the basin was a fussy little steamer
towing two large "bawleys". One of the latter showed about ten feet
of mast ending in a jagged stump. The other's mast had been
snapped off close to the deck, and evidently her crew had been
compelled to cut the sails and wreckage clear. The first boat was
more fortunate, for her spars and canvas were lashed to her deck.
CHAPTER XIII
A Find on the Gunfleet
The Scoutmaster's prognostics of a fine day were justified. Up at
dawn, the crew of the Rosalie found the sky was cloudless; not a
ripple disturbed the harbour, while the smoke from a couple of
destroyers getting up steam rose almost vertically in the still air.
The latter, having finished with the engines for the time being, was
exchanging the fume-laden atmosphere of the motor-room for the
pure, early morning air of the North Sea.
By this time the low-lying Essex shore was lost in a haze. According
to the chart, the Naze was three miles away on the starboard
quarter, but as far as visibility went it might have been fifty. Not a
buoy nor another vessel was in sight. The limited horizon was
unbroken.
"So can I," agreed Mr. Armitage. "A dog on board a fishing-smack,
most likely. See anything of a boat?"
"Certainly," agreed Mr. Armitage. "Carry on, Peter. I'll take the
wheel whilst you are gone."
There was no necessity for the Patrol-leader to turn out the port
watch. Already the "watch below" had heard the news and were on
deck.
Quickly the dinghy was cleared away, the davits swung out, and
the boat prepared for lowering. Directly the Rosalie lost way
Stratton, Warkworth, and Hepburn jumped into her. Peter steered
and the others rowed, pulling lustily at the tough ash oars until the
dinghy almost leapt through the water.