100% found this document useful (12 votes)
671 views

Just Enough Programming Logic and Design 1st Edition Joyce Farrell 2024 scribd download

Joyce

Uploaded by

czyrekcordun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (12 votes)
671 views

Just Enough Programming Logic and Design 1st Edition Joyce Farrell 2024 scribd download

Joyce

Uploaded by

czyrekcordun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Download the full version of the ebook at ebookname.

com

Just Enough Programming Logic and Design 1st


Edition Joyce Farrell

https://ebookname.com/product/just-enough-programming-logic-
and-design-1st-edition-joyce-farrell/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Programming Logic and Design Comprehensive 6th Edition


Joyce Farrell

https://ebookname.com/product/programming-logic-and-design-
comprehensive-6th-edition-joyce-farrell/

ebookname.com

Java Programming 5th Edition Joyce Farrell

https://ebookname.com/product/java-programming-5th-edition-joyce-
farrell/

ebookname.com

Object Oriented Programming Using C Fourth Edition Joyce


Farrell

https://ebookname.com/product/object-oriented-programming-using-c-
fourth-edition-joyce-farrell/

ebookname.com

Electronics Projects For Dummies 1st Edition Earl Boysen

https://ebookname.com/product/electronics-projects-for-dummies-1st-
edition-earl-boysen/

ebookname.com
Theory of Mind in Middle Childhood and Adolescence
Integrating Multiple Perspectives 1st Edition Rory T.
Devine
https://ebookname.com/product/theory-of-mind-in-middle-childhood-and-
adolescence-integrating-multiple-perspectives-1st-edition-rory-t-
devine/
ebookname.com

The Oxford Handbook of Political Psychology 3rd Edition


Leonie Huddy

https://ebookname.com/product/the-oxford-handbook-of-political-
psychology-3rd-edition-leonie-huddy/

ebookname.com

The American Way to Change How National Service and


Volunteers Are Transforming America 1st Edition Shirley
Sagawa
https://ebookname.com/product/the-american-way-to-change-how-national-
service-and-volunteers-are-transforming-america-1st-edition-shirley-
sagawa/
ebookname.com

Pudd nhead Wilson Webster s Chinese Traditional Thesaurus


Edition Mark Twain

https://ebookname.com/product/pudd-nhead-wilson-webster-s-chinese-
traditional-thesaurus-edition-mark-twain/

ebookname.com

Biophilia Edward O. Wilson

https://ebookname.com/product/biophilia-edward-o-wilson/

ebookname.com
Contemporary Ergonomics and Human Factors 2014 Proceedings
of the international conference on Ergonomics Human
Factors 2014 Southampton UK 7 10 April 2014 1st Edition
Sarah Sharples
https://ebookname.com/product/contemporary-ergonomics-and-human-
factors-2014-proceedings-of-the-international-conference-on-
ergonomics-human-factors-2014-southampton-uk-7-10-april-2014-1st-
edition-sarah-sharples/
ebookname.com
JUST ENOUGH PROGRAMMING
LOGIC AND DESIGN
This page intentionally left blank
JUST ENOUGH
PROGRAMMING
LOGIC AND DESIGN

J O Y C E FA R R E L L

Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
Just Enough Programming © 2010 Course Technology, Cengage Learning
Logic and Design
ALL RIGHTS RESERVED. No part of this work covered by the copyright
Joyce Farrell
herein may be reproduced, transmitted, stored or used in any form or by
any means graphic, electronic, or mechanical, including but not limited to
Executive Editor: Marie Lee
photocopying, recording, scanning, digitizing, taping, Web distribution,
Acquisitions Editor: Amy Jollymore information networks, or information storage and retrieval systems, except
Managing Editor: Tricia Coia as permitted under Section 107 or 108 of the 1976 United States Copyright
Developmental Editor: Dean Robbins Act, without the prior written permission of the publisher.

Editorial Assistant: Julia Leroux-Lindsey


For product information and technology assistance, contact us at
Marketing Manager: Bryant Chrzan Cengage Learning Customer & Sales Support, 1-800-354-9706
Content Project Manager: Matt Hutchinson For permission to use material from this text or product,
Art Director: Marissa Falco submit all requests online at www.cengage.com/permissions
Manufacturing Coordinator: Julio Esperas Further permissions questions can be emailed to
[email protected]
Proofreader: Harold Johnson
Indexer: Liz Cunningham ISBN-13: 978-1-4390-3957-1
Compositor: International Typesetting
ISBN-10: 1-4390-3957-7
and Composition

Course Technology
20 Channel Center Street
Boston, MA 02210
USA

Cengage Learning is a leading provider of customized learning solutions with


office locations around the globe, including Singapore, the United Kingdom,
Australia, Mexico, Brazil, and Japan. Locate your local office at:
international.cengage.com/region

Cengage Learning products are represented in Canada by


Nelson Education, Ltd.

For your course and learning solutions, visit www.cengage.com


Purchase any of our products at your local college store or at our preferred
online store www.ichapters.com

Printed in Canada
1 2 3 4 5 6 7 14 13 12 11 10
Brief Contents
v

Preface . . . . . . . . . . . . . . . . . . x
CHAPTER 1 An Overview of Computers and Logic . . . . 1
CHAPTER 2 U n d e r s t a n d i n g S t r u c t u re . . . . . . . . . . 3 1
CHAPTER 3 Making Decisions . . . . . . . . . . . . . 65
CHAPTER 4 Looping . . . . . . . . . . . . . . . . 109
CHAPTER 5 Arrays . . . . . . . . . . . . . . . . . 142
CHAPTER 6 Using Methods . . . . . . . . . . . . . 171
CHAPTER 7 O b j e c t - O r i e n t e d P ro g r a m m i n g . . . . . . . 2 0 4
APPENDIX A Understanding Numbering Systems
and Computer Codes. . . . . . . . . . . 224
APPENDIX B Tw o S p e c i a l S t r u c t u re s —c a s e
and do-while . . . . . . . . . . . . . 229
Index . . . . . . . . . . . . . . . . . 235
Contents
vi

Preface . . . . . . . . . . . . . . . . . . x

CHAPTER 1 An Overview of Computers and Logic . . . . 1


Understanding Computer Components and Operations . . . . 2
Understanding the Programming Process . . . . . . . . . . 6
Understanding the Problem . . . . . . . . . . . . . . . . 6
Planning the Logic . . . . . . . . . . . . . . . . . . . . 7
Coding the Program . . . . . . . . . . . . . . . . . . . 8
Using Software to Translate the Program
into Machine Language . . . . . . . . . . . . . . . . . 8
Testing the Program . . . . . . . . . . . . . . . . . . . 9
Putting the Program into Production . . . . . . . . . . . . 11
Maintaining the Program . . . . . . . . . . . . . . . . . 11
Using Pseudocode Statements and Flowchart Symbols . . . . 11
The Advantages of Repetition . . . . . . . . . . . . . . . 14
Using and Naming Variables and Constants . . . . . . . . . 16
Assigning Values to Variables . . . . . . . . . . . . . . . 17
Performing Arithmetic Operations . . . . . . . . . . . . . 19
Understanding Data Types and Declaring Variables . . . . . . 19
Ending a Program by Using Sentinel Values . . . . . . . . . 21
Understanding the Evolution of
Programming Techniques . . . . . . . . . . . . . . . . . 24
Review Questions . . . . . . . . . . . . . . . . . . . . . 25
Find the Bugs . . . . . . . . . . . . . . . . . . . . . . . 27
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 27

CHAPTER 2 U n d e r s t a n d i n g S t r u c t u re . . . . . . . . . . 3 1
Understanding Unstructured Spaghetti Code . . . . . . . . . 32
Understanding the Three Basic Structures:
Sequence, Selection, and Loop . . . . . . . . . . . . . . 34
Using the Priming Input. . . . . . . . . . . . . . . . . . . 42
Understanding the Reasons for Structure . . . . . . . . . . 49
CONTENTS

Recognizing Structure and Structuring


Unstructured Logic . . . . . . . . . . . . . . . . . . . . 49
Structuring the Dog-Washing Process . . . . . . . . . . . 54
Review Questions . . . . . . . . . . . . . . . . . . . . . 58
Find the Bugs . . . . . . . . . . . . . . . . . . . . . . . 60
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 61 vii

CHAPTER 3 Making Decisions . . . . . . . . . . . . . 65


Evaluating Boolean Expressions to Make Comparisons . . . . 66
Using the Relational Comparison Operators . . . . . . . . . 70
Understanding AND Logic . . . . . . . . . . . . . . . . . 72
Nesting and Decisions for Efficiency . . . . . . . . . . . . 74
Combining Decisions Using the AND Operator . . . . . . . 77
Avoiding Common Errors in an AND Selection. . . . . . . . 79
Understanding OR Logic . . . . . . . . . . . . . . . . . . 82
Writing OR Decisions for Efficiency . . . . . . . . . . . . 84
Combining Decisions in an OR Selection . . . . . . . . . . 85
Avoiding Common Errors in an OR Selection . . . . . . . . 87
Making Selections Within Ranges . . . . . . . . . . . . . . 91
Avoiding Common Errors When Using Range Checks . . . . 93
Understanding Precedence When Combining
AND and OR Operators . . . . . . . . . . . . . . . . . . 97
Review Questions . . . . . . . . . . . . . . . . . . . . . 99
Find the Bugs . . . . . . . . . . . . . . . . . . . . . . 102
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 103

CHAPTER 4 Looping . . . . . . . . . . . . . . . . 109


Understanding the Advantages of Looping . . . . . . . . . 110
Controlling Loops with Counters and Sentinel Values . . . . 110
Using a Definite while Loop with a Counter . . . . . . . 111
Using an Indefinite while Loop with a Sentinel Value . . . 113
Nested Loops . . . . . . . . . . . . . . . . . . . . . . 117
Mixing Constant and Variable Sentinel Values . . . . . . . 119
Avoiding Common Loop Mistakes . . . . . . . . . . . . . 123
Mistake: Neglecting to Initialize the Loop Control Variable . . 123
Mistake: Neglecting to Alter the Loop Control Variable . . 125
Mistake: Using the Wrong Comparison with the
Loop Control Variable . . . . . . . . . . . . . . . . . 127
Mistake: Including Statements Inside the Loop
that Belong Outside the Loop . . . . . . . . . . . . . 127
Using a for Loop . . . . . . . . . . . . . . . . . . . . 129
CONTENTS

Common Loop Applications . . . . . . . . . . . . . . . . 131


Using a Loop to Accumulate Totals . . . . . . . . . . . 131
Using a Loop to Validate Data . . . . . . . . . . . . . . 133
Review Questions . . . . . . . . . . . . . . . . . . . . 135
Find the Bugs . . . . . . . . . . . . . . . . . . . . . . 138
viii Exercises . . . . . . . . . . . . . . . . . . . . . . . . 138

CHAPTER 5 Arrays . . . . . . . . . . . . . . . . . 142


Understanding Arrays and How They Occupy
Computer Memory . . . . . . . . . . . . . . . . . . . 143
How Arrays Occupy Computer Memory . . . . . . . . . . 143
Manipulating an Array to Replace Nested Decisions . . . . . 145
Using Constants with Arrays . . . . . . . . . . . . . . 153
Searching an Array Using a while Loop. . . . . . . . . . 153
Using Parallel Arrays . . . . . . . . . . . . . . . . . . . 156
Improving Search Efficiency. . . . . . . . . . . . . . . 160
Remaining Within Array Bounds . . . . . . . . . . . . . . 161
Using a for Loop to Process Arrays . . . . . . . . . . . 163
Review Questions . . . . . . . . . . . . . . . . . . . . 164
Find the Bugs . . . . . . . . . . . . . . . . . . . . . . 166
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 166

CHAPTER 6 Using Methods . . . . . . . . . . . . . 171


Understanding Modularity. . . . . . . . . . . . . . . . . 172
Modularization Provides Abstraction and Eliminates
Repetition . . . . . . . . . . . . . . . . . . . . . . 172
Modularization Allows Multiple Programmers to Work
on a Problem . . . . . . . . . . . . . . . . . . . . 173
Modularization Makes It Easier to Reuse Your Work . . . . 174
Creating a Method . . . . . . . . . . . . . . . . . . . . 174
Modularizing Program Logic to Avoid Unnecessary
Repetition . . . . . . . . . . . . . . . . . . . . . . 175
Modularizing a Program for Functional Cohesion
and Portability . . . . . . . . . . . . . . . . . . . . 180
Understanding Scope . . . . . . . . . . . . . . . . . . 183
Creating Methods That Require a Single Parameter . . . . . 186
Creating Methods That Require Multiple Parameters. . . . . 190
Creating Methods That Return Values . . . . . . . . . . . 191
Understanding Implementation Hiding . . . . . . . . . . . 196
Using Prewritten Built-In Methods . . . . . . . . . . . . . 197
Review Questions . . . . . . . . . . . . . . . . . . . . 198
Find the Bugs . . . . . . . . . . . . . . . . . . . . . . 201
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 201
CONTENTS

CHAPTER 7 O b j e c t - O r i e n t e d P ro g r a m m i n g . . . . . . . 2 0 4
An Overview of Some Principles of Object-Oriented
Programming . . . . . . . . . . . . . . . . . . . . . 205
Defining a Class . . . . . . . . . . . . . . . . . . . . . 206
Instantiating an Object . . . . . . . . . . . . . . . . . . 208
Understanding Public and Private Access . . . . . . . . . 210 ix
Understanding Inheritance . . . . . . . . . . . . . . . . 213
Understanding Polymorphism . . . . . . . . . . . . . . . 214
Understanding Encapsulation . . . . . . . . . . . . . . . 215
Advantages of Object-Oriented Programming . . . . . . . 217
Review Questions . . . . . . . . . . . . . . . . . . . . 218
Find the Bugs . . . . . . . . . . . . . . . . . . . . . . 220
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 221

APPENDIX A Understanding Numbering Systems


and Computer Codes. . . . . . . . . . . 224

APPENDIX B Tw o S p e c i a l S t r u c t u re s —c a s e
and do-while . . . . . . . . . . . . . 229

Index . . . . . . . . . . . . . . . . . 235
Preface
x

Just Enough Programming Logic and Design is a guide to developing


structured program logic for the beginning programmer. This book
contains only seven chapters and two appendices—just enough to
get the student comfortable with programming logic before tackling
the syntax of a programming language. This book is intended to pro-
vide a complete, sound, yet compact, start in logic—just enough for a
short logic course, just enough as an accompaniment to a program-
ming language book, or just enough as a supplement to a computer
literacy course.
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 mathemati-
cal background beyond high school business math. All the examples
illustrate one or two major points; they do not contain so many fea-
tures that students become lost following irrelevant and extraneous
details. Advanced logical concepts such as file handling, multidimen-
sional arrays, and overloading methods are not covered. This book
provides just enough material for a solid background in logic, no
matter what programming languages students eventually use to
write programs.

Organization and Coverage


Just Enough Programming Logic and Design introduces students to
programming concepts and enforces good style and logical thinking.
General programming concepts are introduced in Chapter 1. Chapter 2
discusses the key concepts of structure, including what structure is, how
to recognize it, and, most importantly, the advantages to writing struc-
tured programs. Chapters 3, 4, 5, and 6 cover selections, loops, arrays,
and methods. Chapter 7 is a straightforward, plain language introduc-
tion to the concepts of object-oriented programming. Two appendices
allow students to gain extra experience with using the binary numbering
system and understanding case and do-while structures.
Just Enough Programming Logic and Design combines text explana-
tion with flowcharts and pseudocode examples to provide students
P R E FA C E

with alternative means of expressing structured logic. Multiple


choice review questions, debugging exercises, and numerous detailed,
full-program exercises at the end of each chapter illustrate the con-
cepts explained within the chapter, and reinforce understanding and
retention of the material presented.
xi
Teaching Tools and Supplements
The following supplemental materials are available when this book
is used in a classroom setting. All of the teaching tools available
with this book are provided to the instructor on a single CD-ROM.
Just Enough Programming Logic and Design is a superior textbook
because it includes the following features:
• Electronic Instructor’s Manual. The Instructor’s Manual that
accompanies this textbook provides additional instructional mate-
rial to assist in class preparation, including items such as Sample
Syllabi, Chapter Outlines, Technical Notes, Lecture Notes, Quick
Quizzes, Teaching Tips, Discussion Topics, and Key Terms.
• ExamView®. This textbook is accompanied by ExamView, a pow-
erful testing software package that allows instructors to create and
administer printed, computer (LAN-based), and Internet exams.
ExamView includes hundreds of questions that correspond to the
topics covered in this text, enabling students to generate detailed
study guides that include page references for further review. The
computer-based and Internet testing components allow students
to take exams at their computers, and save the instructor time by
grading each exam automatically.
• PowerPoint Presentations. This book comes with Microsoft
PowerPoint slides for each chapter. These are included as a teach-
ing aid for classroom presentation, to make available to students
on your network for chapter review, or to be printed for class-
room distribution. Instructors can add their own slides for addi-
tional topics they introduce to the class.
• Solutions. Suggested solutions to Review Questions and Exercises
are provided on the Instructor Resources CD-ROM and may also
be found on the Course Technology Web site at www.cengage.com/
coursetechnology. The solutions are password protected.
• Distance Learning. Course Technology offers online WebCT
and Blackboard (versions 5.0 and 6.0) courses for this text to
provide the most complete and dynamic learning experience pos-
sible. When you add online content to one of your courses, you’re
P R E FA C E

adding a lot: automated tests, topic reviews, quick quizzes, and


additional case projects with solutions. For more information on
how to bring distance learning to your course, contact your local
Course Technology sales representative.
Accompanying Software:
xii
• Visual Logic™, version 2.0: Visual LogicTM is a simple but pow-
erful tool for teaching programming logic and design without
traditional high-level programming language syntax. Visual Logic
uses flowcharts to explain essential programming concepts, including
variables, input, assignment, output, conditions, loops, procedures,
graphics, arrays, and files. It also has the ability to interpret and
execute flowcharts, providing students with immediate and accu-
rate feedback about their solutions. By executing student solutions,
Visual Logic combines the power of a high-level language with the
ease and simplicity of flowcharts. You may purchase Visual Logic
along with your text. Please contact your Course Technology sales
representative for more information.

Acknowledgments
I would like to thank all of the people who helped to make this book
a reality, especially Dean Robbins, Development Editor, whose atten-
tion to detail has made this a quality textbook. Thanks also to Tricia
Coia, Managing Editor, and Amy Jollymore, Acquisitions Editor, for
their support of this project. I am always grateful to Green Pen QA,
Technical Editors, for their expertise. I also appreciate the helpful
comments from Ann Shaffer throughout this book’s development.
Finally, thanks to Matt Hutchinson and Anupriya Tyagi, who master-
minded the process of turning the manuscript into a printed book.
I thank the reviewers who provided helpful and insightful comments
during the development of this book, including Katie Danko, Grand
Rapids Community College; Dawn Pantaleo, Kalamazoo Valley
Community College; Marie Pullan, Farmingdale State College; and
John Thacher, Gwinnett Technical College. As always, thanks to my
husband, Geoff, for his constant support.
—Joyce Farrell
An Overview
CHAPTER 1
of Computers
and Logic

After completing this chapter you will be able to:

 Explain computer components and operations


 Discuss the steps involved in the programming process
 Use pseudocode statements and flowchart symbols
 Use and name variables and constants
 Explain data types and declare variables
 End a program by using sentinel values
 Discuss the evolution of programming techniques
CHAPTER 1 An Overview of Computers and Logic

Understanding Computer
Components and Operations
Hardware and software are the two major components of any com-
puter system.
2 Hardware is the equipment, or the devices, associated with a com-
puter. For a computer to be useful, however, it needs more than
equipment; a computer needs to be given instructions. Just as your
stereo equipment does not do much until you provide music on a CD
or tape, computer hardware needs instructions that control how and
when data items are input, how they are processed, and the form in
which they are output or stored.
Software can Software is computer instructions; software tells the hardware what
be classified to do. Software is programs; instruction sets written by program-
as application mers. You can buy prewritten programs (such as Microsoft Word,
software or iTunes, or Halo) that are stored on a disk or that you download from
system soft- the Web. Alternately, you can write your own programs. When you
ware. Application soft-
write software instructions, you are programming.
ware comprises all the
programs you apply to a Together, computer hardware and software accomplish three major
task—word-processing operations:
programs, spreadsheets,
payroll and inventory • Input—Hardware devices that perform input operations include
programs, and even keyboards and mice. Through these devices, data, or facts, enter
games. System software the computer system.
comprises the programs
you use to manage your • Processing—Processing data items may involve organizing them,
computer, including oper- checking them for accuracy, or performing mathematical opera-
ating systems, such as tions on them. The hardware component that performs these sorts
Windows, Linux, or UNIX. of tasks is the central processing unit, or CPU.
• Output—After data items have been processed, the resulting infor-
Data items mation usually is sent to a printer, monitor, or some other output
include all the device so people can view, interpret, and use the results. Sometimes,
text, numbers,
you store output on hardware, such as a disk or flash media. People
and other
information
cannot read data directly from these storage devices, but the devices
that are processed by hold information for later retrieval. When you send output to a stor-
a computer. However, age device, sometimes it later is used as input for another program.
many computer profes-
You write computer instructions in a computer programming
sionals reserve the term
“information” for data language, such as Visual Basic, C#, C++, or Java. Just as some people
items that have been speak English and others speak Japanese, programmers also write
processed. For example, programs in different languages. Some programmers work exclusively
your name, Social in one language, whereas others know several and use the one that
Security number, and seems most appropriate for the task at hand.
hourly pay rate are data
items, but your paycheck No matter which programming language a computer programmer
holds information. uses, the language has rules governing its word usage and punctuation.
Understanding Computer Components and Operations

These rules are called the language’s syntax. If you ask, “How the geet The instruc-
too store do I?” in English, most people can figure out what you proba- tions you write
bly mean, even though you have not used proper English syntax—you are called
have mixed up the word order, misspelled a word, and used the wrong program
code; when
word. However, computers are not nearly as smart as most people;
you write a program,
with a computer, you might as well have asked, “Xpu mxv ot dodnm you are coding the pro- 3
cadf B?” Unless the syntax is perfect, the computer cannot interpret gram. Program code is
the programming language instruction at all. also called source code.

Every computer operates on circuitry that consists of millions of on/


off switches. Each programming language uses a piece of software
to translate the specific programming language statements into Machine lan-
guage is also
the computer’s on/off circuitry language, or machine language.
called object
Machine language is represented as a series of 0s and 1s, also called code.
binary form. The language translation software that converts a
programmer’s statements to binary form is called a compiler or
interpreter, and it tells you if you have used a programming lan-
guage incorrectly. Therefore, syntax errors are relatively easy to Although there
are differ-
locate and correct—the compiler or interpreter you use highlights
ences in how
every syntax error. If you write a computer program using a language compilers and
such as C++ but spell one of its words incorrectly or reverse the interpreters
proper order of two words, the compiler or interpreter lets you know work, their basic function
that it found a mistake by displaying an error message as soon as you is the same—to translate
try to translate the program. your programming state-
ments into code the com-
When a program’s instructions are carried out, the program executes. puter can use. Usually,
A program that is free of syntax errors can be executed, but it might you do not choose which
not produce correct results. For a program to work properly, you type of translation to
must give the instructions to the computer in a specific sequence, you use—it depends on the
must not leave any instructions out, and you must not add extraneous programming language.
However, there are some
instructions. By doing this, you are developing the logic of the com-
languages for which both
puter program. compilers and interpret-
Suppose you instruct someone to make a cake as follows: ers are available.

Stir
Add two eggs
Don’t Do It
Add a gallon of gasoline Don’t bake a cake
like this!
Bake at 350 degrees for 45 minutes
Add three cups of flour
The dangerous cake-baking instructions are shown with a warning
icon. You will see this icon when a table or figure contains a program-
ming practice that is being used as an example of what not to do.
Even though the cake-baking instructions use correct English
spelling and grammar, the instructions are out of sequence, some
CHAPTER 1 An Overview of Computers and Logic

instructions are missing, and some instructions belong to proce-


dures other than baking a cake. If you follow these instructions, you
are not going to end up with an edible cake, and you may end up
with a disaster. Such logical errors are much more difficult to locate
than syntax errors. The incorrect cake recipe example is extreme, but
suppose the error was more subtle. For example, the correct recipe
4
might require three eggs instead of two, or might require a teaspoon
of vanilla. It is easy for you to determine whether “eggs” is spelled
incorrectly in a recipe, but perhaps impossible for you to know if
there are too few eggs until after the cake is baked and you taste
it. Similarly, it is easy for a compiler or interpreter to locate syntax
errors, but often impossible for it to locate logical errors until the
program executes.
Programmers call some code errors semantic errors. For example,
if you misspell a programming language word, you commit a syntax
error, but if you use an otherwise correct word that does not make
any sense in the current context, you commit a semantic error.
Just as baking directions can be given correctly in French, German,
or Spanish, the same logic of a program can be expressed in any
number of programming languages. This book is almost exclusively
concerned with the logic development process. Because this book
is not concerned with any specific language, the programming
examples could have been written in Japanese, C++, or Java. The
logic is the same in any language. For convenience, the book uses
English!
Once instructions have been input to the computer and translated
into machine language, a program can execute. You can write a
program that takes a number (an input step), doubles it (processing),
and tells you the answer (output) in a programming language such as
Java or C++, but if you were to write it using English-like statements,
it would look like this:
Input originalNumber.
Compute calculatedAnswer as originalNumber times 2.
Output calculatedAnswer.

You will learn The instruction to Input originalNumber is an example of an input


about the odd operation. When the computer interprets this instruction, it knows
elimination to look to an input device to obtain a number. Computers often have
of the space
several input devices, perhaps a keyboard, a mouse, and a CD drive.
between words
like “original” and “Number”
When you learn a specific programming language, you learn how
in the next few pages. to tell the computer which of those input devices to access for input
for the current program. Logically, however, it doesn’t really matter
which hardware device is used, as long as the computer knows to look
for a number. The logic of the input operation—that the computer
Understanding Computer Components and Operations

must obtain a number for input, and that the computer must obtain
it before multiplying it by 2—remains the same regardless of any spe-
cific input hardware device. The same is true in your daily life. If your
boss says to you, “Get Joe Parker’s phone number for me,” it does not
really matter where the number comes from. For example, you might
look it up in a phone book, consult your cell phone’s record of stored
5
numbers, search for the number on the Internet, or phone a friend
who knows the number.
The step that occurs when the arithmetic is performed to double
originalNumber is an example of a processing step. Mathematical
operations are not the only kind of processing, but they are very typi-
cal. After you write a program, the program can be used on comput-
ers of different brand names, sizes, and speeds. When you make a
phone call, your message gets through whether you use a land line or
a cell phone, and it doesn’t matter whether your cell phone is made
by Motorola, Nokia, or Samsung. Similarly, whether you use an IBM, A computer
Macintosh, Linux, or UNIX operating system, and whether you use system needs
a personal computer that sits on your desk or a mainframe that costs both internal
hundreds of thousands of dollars and resides in a special building in a memory and
university, multiplying by 2 is the same process. The hardware is not external stor-
age. Internal memory
important; the logical process is.
is needed to run the
In the number-doubling program, the Output calculatedAnswer programs, but internal
statement represents an output operation. Within a particular memory is volatile—that
is, its contents are lost
program, this statement could cause the output to appear on the
every time the computer
monitor (which might be a flat panel screen or a cathode-ray tube),
loses power. External
or the output could go to a printer (which could be laser or ink- storage (such as a disk)
jet), or the output could be written to a disk or CD. The logic of the provides a nonvolatile (or
process called Output is the same no matter what hardware device persistent) medium.
you use.
To use a computer program, you must first load it into the computer’s
memory. Memory is the internal storage in a computer, often called Computer
main memory or random access memory (RAM). You might type memory con-
a program’s instructions into memory from the keyboard, or you sists of millions
might load a program that has already been written and stored on a of numbered
disk. Either way, a copy of the instructions must be placed in memory locations
where data can be stored.
before the program can be run.
Every named item such as
Once you have a copy of a program in memory, you want to exe- originalNumber has a
cute, or run, the program. When you run the number-doubling pro- specific numeric address
associated with it. Every
gram, it requires a piece of data—a value for originalNumber. The
time you refer to a named
originalNumber—for example, 8—is also placed in main memory at
item within a program, the
a specific location that the program will call originalNumber. Then, computer retrieves the
and only then, can the calculatedAnswer, in this case 16, be calcu- value at the associated
lated and output. memory location.
CHAPTER 1 An Overview of Computers and Logic

Computer Understanding the Programming Process


programmers
often refer A programmer’s job involves writing instructions (such as the three
to memory instructions in the doubling program in the preceding section), but
addresses a professional programmer usually does not just sit down at a com-
using hexadecimal nota-
puter keyboard and start typing. The programmer’s job can be broken
6 tion, or base 16. With
down into seven development steps:
this system, they might
use a value like 42FF01A 1. Understanding the problem
to refer to a memory
address. Despite the 2. Planning the logic
use of letters, such an
address is still a number.
3. Coding the program
Appendix A contains infor- 4. Using software (a compiler or interpreter) to translate the
mation on the hexadeci-
program into machine language
mal numbering system.
5. Testing the program
6. Putting the program into production
7. Maintaining the program
Figure 1-1 illustrates the program development cycle.

Understand
the problem

Maintain the Plan the


program logic

Put the program Write the


into production code

Test the Translate the


program code

Figure 1-1 The program development cycle

Understanding the Problem


Professional computer programmers write programs to satisfy the needs
of others. Examples could include a Human Resources Department that
needs a printed list of all employees, a Billing Department that wants a
list of clients who are 30 or more days overdue on their payments, and
an Order Department that needs a Web site to provide buyers with an
Understanding the Programming Process

online shopping cart in which to gather their orders. Because program-


mers are providing a service to these users, programmers must first
understand what it is the users want.
Suppose the director of human resources says to a programmer, “Our
department needs a list of all employees who have been here more than
five years, because we want to invite them to a special thank-you dinner.” 7
On the surface, this seems like a simple enough request. An experienced
programmer, however, will know that he or she may not yet understand
the whole problem. Does the director want a list of full-time employ-
ees only, or a list of full- and part-time employees together? Does she
want people who have worked for the company on a month-to-month
contractual basis over the past five years, or only regular, permanent
employees? Do the listed employees need to have worked for the orga-
nization for five years as of today, as of the date of the dinner, or as of
some other cutoff date? What about an employee who worked three
years, took a two-year leave of absence, and has been back for three
years? Does he or she qualify? The programmer cannot make any of
these decisions; the user is the one who must address these questions.
More decisions still might be required. For example, what does the user
want the report of five-year employees to look like? Should it contain
both first and last names? Social Security numbers? Phone numbers?
Addresses? Is all this data available? Several pieces of documentation
are often provided to help the programmer understand the problem.
This documentation might include items such as a sample of what the
output will look like and lists of data that are available in company files.
Really understanding the problem may be one of the most difficult
aspects of programming. On any job, the description of what the user
needs may be vague—worse yet, the users may not even really know
what they want, and users who think they know what they want fre-
You may hear
quently change their minds after seeing sample output. A good pro-
program-
grammer is often part counselor, part detective! mers refer
to planning
Planning the Logic a program
as “developing an algo-
The heart of the programming process lies in planning the program’s rithm.” An algorithm is
logic. During this phase of the programming process, the programmer the sequence of steps
plans the steps of the program, deciding what steps to include and how necessary to solve any
problem.
to order them. You can plan the solution to a problem in many ways.
The two most common planning tools are flowcharts and pseudocode.
Both tools involve writing the steps of the program in English, much You will learn
as you would plan a trip on paper before getting into the car, or plan a more about
party theme before going shopping for food and favors. flowcharts
and pseudo-
The programmer shouldn’t worry about the syntax of any particular code later in
language at this point, just about figuring out what sequence of events this chapter.
CHAPTER 1 An Overview of Computers and Logic

will lead from the available input to the desired output. Planning
a program’s logic includes thinking carefully about all the possible
data values a program might encounter and how you want the pro-
gram to handle each scenario. The process of walking through a
program’s logic on paper before you actually write the program is
called desk-checking. You will learn more about planning the logic
8
later; in fact, this book focuses on this crucial step almost exclusively.

Coding the Program


Once the programmer has developed the logic of a program, only then
can he or she code the program in one of more than 400 programming
languages. Programmers choose a particular language because some
languages have built-in capabilities that make them more efficient
than others at handling certain types of operations. Despite their dif-
ferences, programming languages are quite alike—each can handle
input operations, arithmetic processing, output operations, and other
standard functions. The logic developed to solve a programming prob-
lem can be executed using any number of languages. It is only after a
language is chosen that the programmer must worry about each com-
mand being spelled correctly and all of the punctuation getting into
the right spots—in other words, using the correct syntax.
Some very experienced programmers can successfully combine logic
planning and program coding in one step. This may work for plan-
ning and writing a very simple program, just as you can plan and
write a postcard to a friend using one step. A good term paper or a
Hollywood screenplay, however, needs planning before writing, and
so do most programs.
Which step is harder, planning the logic or coding the program? Right
now, it may seem to you that writing in a programming language is
a very difficult task, considering all the spelling and grammar rules
you must learn. However, the planning step is actually more difficult.
Which is more difficult: thinking up the twists and turns to the plot of
a bestselling mystery novel, or writing a translation of an already writ-
ten novel from English to Spanish? And who do you think gets paid
more, the writer who creates the plot or the translator? (Try asking
friends to name any famous translator!)

Using Software to Translate the Program


into Machine Language
Even though there are many programming languages, each computer
is built knowing only one language, its machine language, which con-
sists of many 1s and 0s. Computers understand machine language
because computers themselves are made up of thousands of tiny
Understanding the Programming Process

electrical switches, each of which can be set in either the on or off


state, which is represented by a 1 or 0, respectively.
Languages like Java or Visual Basic are available for programmers to
use because someone has written a translator program (a compiler or
interpreter) that changes the English-like high-level programming
language in which the programmer writes into the low-level 9
machine language that the computer understands. If you write a
programming language statement incorrectly (for example, by mis-
spelling a word, using a word that doesn’t exist in the language, or
using “illegal” grammar), the translator program does not know how
to proceed and issues an error message identifying a syntax error–a
misuse of a language’s grammar rules. Although making errors is
never desirable, syntax errors are not a major concern to program-
mers because the compiler or interpreter catches every syntax error,
and displays a message that notifies you of the problem. The com-
puter will not execute a program that contains even one syntax error.
A computer program must be free of syntax errors before you can
execute it. Typically, a programmer develops a program’s logic, writes
the code, and then attempts to compile or interpret the program using
language-interpreting software. Usually, the software displays a list of
syntax errors, which the programmer corrects. Then, the programmer
attempts another translation. Correcting the first set of errors frequently
reveals new errors that originally were not apparent to the compiler.
For example, if you could use an English compiler and submit the
sentence “the dg chase the cat”, the compiler at first would point out
only one syntax error to you. The second word, “dg”, is illegal because
it is not part of the English language. Only after you corrected the
word “dog” would the compiler find another syntax error on the third
word, “chase”, because it is the wrong verb form for the subject “dog”.
This doesn’t mean “chase” is necessarily the wrong word. Maybe “dog”
is wrong; perhaps the subject should be “dogs”, in which case “chase”
is right. Compilers don’t always know exactly what you mean, nor do
they know what the proper correction should be, but they do know
when something is wrong with your syntax.
When writing a program, a programmer might need to retranslate
the code several times. An executable program is created only when
the code is free of syntax errors.

Testing the Program


A program that is free of syntax errors is not necessarily free of
logical errors. For example, the sentence “The dog chases the cat”,
although syntactically perfect, is not logically correct if the dog chases
a ball or the cat is the aggressor.
CHAPTER 1 An Overview of Computers and Logic

Once a program is free from syntax errors, the programmer can


test it—that is, execute it with some sample data to see whether the
results are logically correct. Recall the number-doubling program:
Input originalNumber.
Compute calculatedAnswer as originalNumber times 2.
Output calculatedAnswer.
10
If you provide the value 2 as input to the program and the answer 4 is
displayed as output, you have executed one successful test run of the
program.
However, if the answer 40 is displayed as output, maybe it’s because
the program contains a logical error. Maybe the second line of code
was mistyped with an extra zero, so that the program reads:
The programmer typed “20”
instead of “2”.
Input originalNumber.
Compute calculatedAnswer as originalNumber times 20.
Output calculatedAnswer.
The error of placing 20 instead of 2 in the multiplication statement
caused a logical error. Notice that nothing is syntactically wrong
with this second program—it is just as reasonable to multiply a
number by 20 as by 2—but if the programmer intends only to
double originalNumber, then a logical error has occurred.
Programs should be tested with many sets of data. For example, if
you write the program to double a number and enter 2 and get an
output value of 4, that doesn’t necessarily mean you have a correct
program. Perhaps you have typed this program by mistake:
The programmer did not
mean to use “plus”.
Input originalNumber.
Compute calculatedAnswer as originalNumber plus 2.
Output calculatedAnswer.

An input of 2 results in an answer of 4, but that doesn’t mean your


program doubles numbers—it actually only adds 2 to them. If you test
your program with additional data and get the wrong answer—for
example, if you enter 3 and produce an answer of 5—you know there
is a problem with your code.
Selecting test data is something of an art in itself, and it should be done
carefully. If the Human Resources Department requests a list of the
names of five-year employees, it would be a mistake to test the pro-
gram you create using a small sample file of only long-term employees.
If no newer employees are part of the data being used for testing, you
do not really know if the program would have eliminated them from
the five-year list. Many companies do not know that their software has
Using Pseudocode Statements and Flowchart Symbols

a problem until an unusual circumstance occurs—for example, the first


time an employee has more than nine dependents, the first time a cus-
tomer orders more than 999 items at a time, the first time a program
is executed during a leap year, or when (in an example that was well
documented in the popular press) a new century begins.
11
Putting the Program into Production
Once the program is tested adequately, it is ready for the organization
to use. Putting the program into production might mean simply run-
ning the program once, if it was written to satisfy a user’s request for
a special list. However, the process might take months if the program
will be run on a regular basis, or if it is one of a large system of pro-
grams being developed. Perhaps data-entry people must be trained
to prepare the input for the new program, users must be trained
to understand the output, or existing data in the company must be
changed to an entirely new format to accommodate this program.
Conversion, the entire set of actions an organization must take to
switch over to using a new program or set of programs, can some-
times take months or years to accomplish.

Maintaining the Program


After programs are put into production, making required changes
is called maintenance. Maintenance is necessary for many reasons:
for example, new tax rates are legislated, the format of an input
file is altered, or the end user requires additional information not
included in the original output specifications. Frequently, your first
programming job will require maintaining previously written pro-
grams. When you maintain the programs others have written, you
will appreciate the effort the original programmer put into writing
clear code, using reasonable identifiers for values, and document-
ing his or her work. When you make changes to existing programs,
you repeat the development cycle. That is, you must understand
the changes, and plan, code, translate, and test them before putting
them into production. If a substantial number of program changes
are required, the original program might be retired, and the pro-
gram development cycle started for a new program.

Using Pseudocode Statements


and Flowchart Symbols
When programmers plan the logic for a solution to a programming
problem, they often use one of two tools, pseudocode (pronounced
“sue-doe-code”) or flowcharts. Pseudocode is an English-like
CHAPTER 1 An Overview of Computers and Logic

representation of the logical steps it takes to solve a problem A


flowchart is a pictorial representation of the same thing. Pseudo is
a prefix that means “false,” and to code a program means to put it in
a programming language; therefore, pseudocode simply means “false
code,” or sentences that appear to have been written in a computer
programming language but do not necessarily follow all the syntax
12
rules of any specific language.
You have already seen examples of statements that represent pseudo-
code earlier in this chapter, and there is nothing mysterious about
them. The following five statements constitute a pseudocode repre-
sentation of a number-doubling problem:
start
input originalNumber
compute calculatedAnswer as originalNumber times 2
output calculatedAnswer
stop

Using pseudocode involves writing down all the steps you will use
in a program. Usually, programmers preface their pseudocode state-
ments with a beginning statement like start and end them with a
terminating statement like stop. The statements between start and
stop look like English and are indented slightly so that start and
stop stand out. Most programmers do not bother with punctua-
tion such as periods at the end of pseudocode statements, although
it would not be wrong to use them if you prefer that style. Similarly,
there is no need to capitalize the first word in a sentence, although
you might choose to do so. This book follows the conventions of
using lowercase letters for verbs that begin pseudocode statements
and omitting periods at the end of statements.
Pseudocode is fairly flexible because it is a planning tool, and not the
final product. Therefore, you might prefer, for example, to use the
terms begin and end instead of start and stop. Instead of writing
input originalNumber, many pseudocode developers would write
get originalNumber or read originalNumber. Instead of writing
output calculatedAnswer, many pseudocode developers would
write display calculatedAnswer or write calculatedAnswer.
The point is, the pseudocode statements mean to retrieve an original
number from an input device and store it in memory where it can
be used in a calculation, and then to get the calculated answer from
memory and send it to an output device so a person can see it. When
you eventually convert your pseudocode to a specific programming
language, you do not have such flexibility because specific syntax will
be required. For example, if you use the C# programming language,
you will code Console.Write(calculatedAnswer);. The capitaliza-
tion, exact use of words, and punctuation are important in the C#
statement; they are not important in the pseudocode statement.
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of The Customs
Lounge
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: The Customs Lounge

Author: Annie Proulx

Release date: February 16, 2020 [eBook #61424]

Language: English

Credits: Produced by Greg Weeks, Mary Meehan and the Online


Distributed Proofreading Team at http://www.pgdp.net

*** START OF THE PROJECT GUTENBERG EBOOK THE CUSTOMS


LOUNGE ***
THE CUSTOMS LOUNGE
BY E. A. PROULX

Anything can happen in the


customs lounge—since they
let those Earth people in!

[Transcriber's Note: This etext was produced from


Worlds of If Science Fiction, September 1963.
Extensive research did not uncover any evidence that
the U.S. copyright on this publication was renewed.]
There were usually a few Customs Inspectors in the lounge, waiting
to begin their shifts, hanging around trading news and incidents and
drinking the bad, lukewarm kasser that was a standing joke in the
Immigration-Customs Service.
Old Grag was telling for perhaps the eightieth time of a success of
his when he was young in the Service.
"... They had this small box of sticky, squashy sweets with them. The
young one was eating one. Many another Inspector would have
passed them through, but I thought the young one chewed too
much and too loud. So I said, 'Mind if I have one?'
"'Wah!' says they together, 'it would set you on edge, Noble Wise
Inspector. It is the taste of another world.' They was Venusers, and
they started shifting and hopping around, and humming their
national anthem, you know how they used to do back in the old
days. I made quite a nice little find. Almost a half-scree of chamfer
in each one of those sweets. I got a promotion out of that, and the
Venusers got a six-year close out."
Inspector Flimp blew one of his noses loudly.
"Hee, that's nothing. I recall back when we first opened up for
Immigration, and a whole shipload of earthers came in. They were
crammed in like tigs in a nest, and as usual they didn't know one
word of the language, they didn't have any idea of where to go or
how to do anything, and they'd got separated from their controller.
They just stood around, huddled together and jabbering at each
other. Well, I checked out about twenty of them, and then there
comes up this big ugly female. Well, I jacks the elevator up some
more, and I looks down at her.
"'Name!', I call. 'Gladdis Cracklegill,' or some other weird earth name
she screams at me. 'Too much name,' I say. 'You've got enough
name there for five of you. Which will you choose, Glad, Is, Crack, El
or Gil?'
"Well, it took me a while to make her understand me—my earth
accent wasn't too good then, and she was slow-headed, having only
one, like all earthers. But I finally made her understand what I
wanted to know, and then, by Clag, what a ramping frowst she did
make!
"It was while she was screeching at me that I noticed her teeth were
pretty big, even for such a huge beast as she was. So I secretly
turned on the Dento-Spyer, right into her jaws, and what a sight on
the view screen! Each of those big teeth was false and filled to the
top with Earth seeds she was trying to smuggle!"
"Earthers!" exploded young Nask. "They make me sick!"
"I'm with you, Nask," said Inspector Sprim. "And I don't understand
why they still keep routing earthers through Immigration anyway.
They claim they're a borderline case, but when you've seen as many
as I have, you know, which side of the border they're on."

Nask went off to the kasser dispenser and his place was taken by
Brif, the head Inspector, who had been listening.
"Un-edge yourself, Sprim," smiled Brif, contracting one of his heads.
"I have good news, rare news and fine news. The Four Council
decision just came down to us. Earthers are now to be routed
through Livestock instead of Immigration beginning very soon."
A cheer went up from the little group of Customs and Immigration
officials. The one Livestock Inspector in the lounge groaned in
despair.
Old Inspector Flimp seemed bothered.
"They've made themselves a mistake," he sputtered. "Earthers can
be clever and tricky even after they're altered. Why, I seen them pull
every trick in the book coming through here. Did I ever tell you
about the stunted one with an artificial head who tried to pass
himself off as a rest-park planner? Well, it seems that...."
Two young, but large inspectors sneaked away from the group when
they saw old Flimp was launched into one of his dull yarns again.
Outside the lounge, after a quick look up and down the hall, they
ducked into the robot-cleaner storage closet.
"Boy," gasped the shorter inspector. "I had to get out of there.
Besides the torture of listening to that two-headed monster babble
on and on about how he outwitted earthers when he was still able to
move around, this miserable thing has started to come loose again."
He gave an impatient wrench to his left head, and it wobbled
enough to expose some of the delicate wires that the earth robotic
engineer had labored over so many hours.
The other began tightening straps and buckles for him.
"There," he said finally. "You look like one of the boys again."
Laughing together, the earthers went back into the Customs Lounge.
*** END OF THE PROJECT GUTENBERG EBOOK THE CUSTOMS
LOUNGE ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like