You are on page 1of 41

Programming Logic and Design,

Comprehensive 9th Edition - eBook


PDF
Visit to download the full and correct content document:
https://ebooksecure.com/download/programming-logic-and-design-comprehensive-9t
h-edition-ebook-pdf/
PROGRAMMING LOGIC
AND DESIGN
COMPREHENSIVE
NINTH EDITION

PROGRAMMING LOGIC
AND DESIGN
COMPREHENSIVE

JOYCE FARRELL

Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
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

Unless otherwise noted all items © Cengage Learning.

Cengage Learning is a leading provider of customized learning


solutions with employees residing in nearly 40 different coun-
tries and sales in more than 125 countries around the world.
Find your local representative at www.cengage.com.

Cengage Learning products are represented in Canada by


Nelson Education, Ltd.

To learn more about Cengage Learning Solutions, visit


www.cengage.com

Purchase any of our products at your local college store or at


our preferred online store www.cengagebrain.com

Printed in the United States of America


Print Number: 01   Print Year: 2018
Brief Contents
v

Pref ace ���������� ����� � ����� ��� � ����� ��� ��� ������ � ����� xvi

CHAPTER 1 An Over view of Computers and Programmi ng � �� 1


CHAPTER 2 Elem en t s o f Hi gh- Qual i ty Programs ����� ��� � �� ��� � 38
CHAPTER 3 U n der s t an din g Structure ��� �� ��� � ��� �� ��� ��� � �� ��� � 87
CHAPTER 4 M akin g Decis i ons ��� � �� ��� ���� �� ��� � ��� �� ��� ��� � �� �� 124
CHAPTER 5 Lo o pin g � ������ ����� ��� � �� ��� ���� �� ��� � ��� �� ��� ��� � �� �� 176
CHAPTER 6 Ar r ays ��� ������ ����� ��� � �� ��� ���� �� ��� � ��� �� ��� ��� � �� �� 227
CHAPTER 7 F ile Han dlin g and Appl i cati ons��� ��� �� ��� ��� � �� �� 272
CHAPTER 8 Advan ced Data Handl i ng Concepts  ��� � �� � �� � �� � �� 321
CHAPTER 9 Advan ced M o dul ari z ati on Techni ques ����� � �� �� 366
CHAPTER 10 Object -Or ien t ed Programmi ng ����� ��� ��� ��� ��� �� 420
CHAPTER 11 M o re Object -Ori ented Programmi ng
Co n cept s ��� ����� ��� ��� ���� ����� ������ ��� ��� ��� ��� ��� �� 464
CHAPTER 12 Even t -Dr iven G UI Programmi ng,
M u lt it h readin g, and Ani mati on����� ��� ��� ��� ��� �� 507
APPENDIX A U n der s t an din g Numberi ng Sy stems
an d Co m pu t er Codes ��� �� ��� ���� �� ������ ��� ������ �� 539
APPENDIX B So lvin g Dif f icul t Structuri ng Probl ems ��� � �� �� 547
Glo s s ar y ��� ����� ��� ��� ������ ��� ��� � �� ��� ��� � ��� �� ��� � � 556
In dex��� ������ ��� ����� ��� ��� ��� ���� �� ���� ����� � ����� ��� �� 571
Contents
vii

Pref ace ���������� ����� � ����� ��� � ����� ��� ��� ������ � ����� xvi

CHAPTER 1 An Over view of Computers and Programmi ng � �� 1


Understanding Computer Systems��������������������������������������� 2
Understanding Simple Program Logic���������������������������������� 5
Understanding the Program Development Cycle��������������������� 8
Understanding the Problem ��������������������������������������������� 8
Planning the Logic ��������������������������������������������������������10
Coding the Program �����������������������������������������������������10
Using Software to Translate the Program into Machine
Language ������������������������������������������������������������������11
Testing the Program �����������������������������������������������������12
Putting the Program into Production��������������������������������13
Maintaining the Program������������������������������������������������14
Using Pseudocode Statements and Flowchart Symbols ���������15
Writing Pseudocode ������������������������������������������������������15
Drawing Flowcharts ������������������������������������������������������17
Repeating Instructions ��������������������������������������������������19
Using a Sentinel Value to End a Program�����������������������������20
Understanding Programming and User Environments ������������23
Understanding Programming Environments�����������������������23
Understanding User Environments�����������������������������������25
Understanding the Evolution of Programming Models������������27
Chapter Summary �����������������������������������������������������������28
Key Terms�����������������������������������������������������������������������29
Exercises �����������������������������������������������������������������������32

CHAPTER 2 Elem en t s o f Hi gh- Qual i ty Programs ����� ��� � �� ��� � 38


Declaring and Using Variables and Constants�����������������������39
Understanding Data Types ���������������������������������������������39
Understanding Unnamed, Literal Constants�����������������������39
Working with Variables ��������������������������������������������������40
Understanding a Declaration’s Data Type��������������������������41
CONTENTS 

Understanding a Declaration’s Identifier ���������������������������42


Assigning Values to Variables �����������������������������������������45
Declaring Named Constants��������������������������������������������46
Performing Arithmetic Operations ��������������������������������������47
The Integer Data Type ���������������������������������������������������50
viii Understanding the Advantages of Modularization �����������������51
Modularization Provides Abstraction��������������������������������52
Modularization Helps Multiple Programmers to Work
on a Problem��������������������������������������������������������������53
Modularization Allows You to Reuse Work��������������������������53
Modularizing a Program ������������������������������������������������54
Declaring Variables and Constants within Modules�����������������58
Understanding the Most Common Configuration
for Mainline Logic�����������������������������������������������������������60
Creating Hierarchy Charts ���������������������������������������������64
Features of Good Program Design��������������������������������������66
Using Program Comments ���������������������������������������������67
Choosing Identifiers������������������������������������������������������69
Designing Clear Statements��������������������������������������������71
Writing Clear Prompts and Echoing Input��������������������������72
Maintaining Good Programming Habits��������������������������������74
Chapter Summary �����������������������������������������������������������75
Key Terms�����������������������������������������������������������������������76
Exercises �����������������������������������������������������������������������79

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
 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
CONTENTS 

Common Loop Applications��������������������������������������������� 205


Using a Loop to Accumulate Totals ������������������������������� 205
Using a Loop to Validate Data��������������������������������������� 209
Limiting a Reprompting Loop ��������������������������������������� 209
Validating a Data Type ������������������������������������������������ 212
x Validating Reasonableness and Consistency of Data��������� 213
Comparing Selections and Loops������������������������������������� 214
Chapter Summary ��������������������������������������������������������� 218
Key Terms��������������������������������������������������������������������� 218
Exercises ��������������������������������������������������������������������� 220

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
 CONTENTS

A Program that Performs File Operations������������������������ 282


Understanding Control Break Logic ���������������������������������� 285
Merging Sequential Files ������������������������������������������������ 290
Master and Transaction File Processing ���������������������������� 299
Random Access Files������������������������������������������������������ 308
Chapter Summary ��������������������������������������������������������� 309 xi
Key Terms��������������������������������������������������������������������� 310
Exercises ��������������������������������������������������������������������� 312

CHAPTER 8 Advan ced Data Handl i ng Concepts  ��� � �� � �� � �� � �� 321


Understanding the Need for Sorting Data��������������������������� 322
Using the Bubble Sort Algorithm��������������������������������������� 324
Understanding Swapping Values������������������������������������ 324
Understanding the Bubble Sort ������������������������������������� 325
Sorting Multifield Records ���������������������������������������������� 340
Sorting Data Stored in Parallel Arrays ��������������������������� 340
Sorting Records as a Whole������������������������������������������ 341
Other Sorting Algorithms ������������������������������������������������ 342
Using Multidimensional Arrays������������������������������������������ 345
Using Indexed Files and Linked Lists��������������������������������� 351
Using Indexed Files ���������������������������������������������������� 352
Using Linked Lists ������������������������������������������������������ 353
Chapter Summary ��������������������������������������������������������� 356
Key Terms��������������������������������������������������������������������� 357
Exercises ��������������������������������������������������������������������� 358

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
CONTENTS 

Chapter Summary ��������������������������������������������������������� 410


Key Terms��������������������������������������������������������������������� 411
Exercises ��������������������������������������������������������������������� 412

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

CHAPTER 11 M o re Object -Ori ented Programmi ng


Co n cept s ��� ����� ��� ��� ���� ����� ������ ��� ��� ��� ��� ��� �� 464
Understanding Constructors ������������������������������������������� 465
Default Constructors��������������������������������������������������� 466
Non-default Constructors��������������������������������������������� 468
Overloading Instance Methods and Constructors ������������� 469
Understanding Destructors ��������������������������������������������� 472
Understanding Composition��������������������������������������������� 474
Understanding Inheritance ���������������������������������������������� 475
Understanding Inheritance Terminology��������������������������� 478
Accessing Private Fields and Methods
of a Parent Class������������������������������������������������������ 481
Overriding Parent Class Methods in a Child Class������������ 486
 CONTENTS

Using Inheritance to Achieve Good Software Design��������� 486


An Example of Using Predefined Classes:
Creating GUI Objects ��������������������������������������������������� 487
Understanding Exception Handling������������������������������������ 488
Drawbacks to Traditional Error-Handling Techniques��������� 489
The Object-Oriented Exception-Handling Model���������������� 491 xiii
Using Built-in Exceptions and Creating
Your Own Exceptions ������������������������������������������������ 493
Reviewing the Advantages of Object-Oriented Programming 494
Chapter Summary ��������������������������������������������������������� 495
Key Terms��������������������������������������������������������������������� 496
Exercises ��������������������������������������������������������������������� 497

CHAPTER 12 Even t -Dr iven G UI Programmi ng,


M u lt it h readin g, and Ani mati on����� ��� ��� ��� ��� �� 507
Understanding Event-Driven Programming ������������������������� 508
User-Initiated Actions and GUI Components������������������������ 511
Designing Graphical User Interfaces��������������������������������� 514
The Interface Should Be Natural and Predictable������������� 514
The Interface Should Be Attractive, Easy to Read,
and Nondistracting ��������������������������������������������������� 515
To Some Extent, It’s Helpful If the User Can Customize
Your Applications������������������������������������������������������ 516
The Program Should Be Forgiving ��������������������������������� 516
The GUI Is Only a Means to an End��������������������������������� 516
Developing an Event-Driven Application������������������������������ 517
Creating Wireframes ��������������������������������������������������� 518
Creating Storyboards��������������������������������������������������� 518
Defining the Storyboard Objects in an Object Dictionary��� 519
Defining Connections Between the User Screens������������� 520
Planning the Logic ������������������������������������������������������ 520
Understanding Threads and Multithreading ������������������������ 525
Creating Animation��������������������������������������������������������� 528
Chapter Summary ��������������������������������������������������������� 531
Key Terms��������������������������������������������������������������������� 532
Exercises ��������������������������������������������������������������������� 533
CONTENTS 

APPENDIX A U n der s t an din g Numberi ng Sy stems


an d Co m pu t er Codes ��� �� ��� ���� �� ������ ��� ������ �� 539

APPENDIX B So lvin g Dif f icul t Structuri ng Probl ems ��� � �� �� 547


xiv
Glo s s ar y ��� �������� ��� ������ ��� ��� � �� ��� ��� � ��� �� ��� � � 556
In dex��� ������ ��� ����� ��� ��� ��� ���� �� ���� ����� � ����� ��� �� 571
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.

Organization and Coverage


Programming Logic and Design, Comprehensive, Ninth Edition, introduces students to
­programming concepts and enforces good style and logical thinking. General programming
concepts are introduced in Chapter 1.
Chapter 2 discusses using data and introduces two important concepts: modularization
and creating high-quality programs. It is important to emphasize these topics early so
that ­students start thinking in a modular way and concentrate on making their programs
­efficient, robust, easy to read, and easy to maintain.
Chapter 3 covers the key concepts of structure, including what structure is, how to
­recognize it, and most importantly, the advantages to writing structured programs. This
chapter’s content is unique among programming texts. The early overview of structure
­presented here provides students a solid foundation for thinking in a structured way.
Chapters 4, 5, and 6 explore the intricacies of decision making, looping, and array
­manipulation. Chapter 7 provides details of file handling so that students can create
­programs that process a significant amount of data.
In Chapters 8 and 9, students learn more advanced techniques in array manipulation and
modularization. Chapters 10 and 11 provide a thorough, yet accessible, introduction to con-
cepts and terminology used in object-oriented programming. Students learn about classes,
objects, instance and static class members, constructors, destructors, inheritance, and the
Organization and Coverage P R E FA C E

advantages of object-oriented thinking. Chapter 12 explores some additional


object-oriented programming issues: event-driven GUI programming, multithreading,
and animation.
Two appendices instruct students on working with numbering systems and providing
structure for large programs. xvii
Programming Logic and Design combines text explanation with flowcharts and ­pseudocode
examples to provide students with alternative means of expressing structured logic.
Numerous detailed, full-program exercises at the end of each chapter illustrate the concepts
explained within the chapter, and reinforce understanding and retention of the material
presented.
Programming Logic and Design distinguishes itself from other programming logic books in
the following ways:
•• It is written and designed to be non-language specific. The logic used in this book can
be applied to any programming language.
•• The examples are everyday business examples: no special knowledge of mathematics,
accounting, or other disciplines is assumed.
•• The concept of structure is covered earlier than in many other texts. Students are
exposed to structure naturally, so that they will automatically create properly designed
programs.
•• Text explanation is interspersed with both flowcharts and pseudocode so that ­students
can become comfortable with these logic development tools and understand their ­inter-
relationship. Screen shots of running programs also are included, providing s­ tudents
with a clear and concrete image of the programs’ execution.
•• Complex programs are built through the use of complete business examples. Students
see how an application is constructed from start to finish, instead of studying only
­segments of a program.
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.

Using a Priming Input to Structure a Program

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

the reader with a visual incorrectly be doubled and


output.
105
Declarations
learning experience. num originalNumber
num calculatedAnswer

THE DON’T DO IT ICON illustrates


Yes how NOT to do something—for
not eof?
example, having a dead code
path in a program. This icon
input
No
originalNumber
stop provides a visual jolt to the student,
calculatedAnswer =
originalNumber * 2

are NOT to be emulated and making


output
calculatedAnswer students more careful to recognize
problems in existing code.

Figure 3-17 Structured but incorrect solution to the number-doubling problem

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.

C9275_Chapter03_hr.indd 105 11/15/16 2:07 PM


 F E AT U R E S

Understanding Simple Program Logic

• The instruction myAnswer = myNumber * 2 is an example of a processing operation.


In most programming languages, an asterisk is used to indicate multiplication, so this
instruction means “Change the value of the memory location myAnswer to equal the
value at the memory location myNumber times two.” Mathematical operations are not the
xix
only kind of processing operations, but they are very typical. As with input operations,
the type of hardware used for processing is irrelevant—after you write a program, it can 7
be used on computers of different brand names, sizes, and speeds.
VIDEO LESSONS help • In the number-doubling program, the output myAnswer instruction is an example of an
explain important chapter
output operation. Within a particular program, this statement could cause the output
to appear on the monitor (which might be a flat-panel plasma screen or a smartphone
concepts. Videos are part
display), or the output could go to a printer (which could be laser or ink-jet), or the
output could be written to a disk or DVD. The logic of the output process is the same no
of the text’s MindTap. matter what hardware device you use. When this instruction executes, the value stored
in memory at the location named myAnswer is sent to an output device. (The output
value also remains in computer memory until something else is stored at the same
memory location or power is lost.)

Watch the video A Simple Program.

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.

TWO TRUTHS & A LIE


Understanding Simple Program Logic

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;

TWO TRUTHS & A LIE mini quizzes


C9275_Chapter01_hr.indd 7 8/23/16 7:50 PM

appear after each chapter section, with


answers provided. The quiz contains
three statements based on the preceding
section of text—two statements are
true and one is false. Answers give
immediate feedback without “giving away”
answers to the multiple-choice questions
and programming problems later in
the chapter. Students also have the option
to take these quizzes electronically
MindTap.
Assessment
PROGRAMMING EXERCISES provide
opportunities to practice chapter material.
These exercises increase in difficulty and
allow students to explore logical program-
xx ming concepts. Most exercises can be
completed using flowcharts, pseudocode,
or both. In addition, instructors can assign
the exercises as programming problems
to be coded and executed in a particular
programming language.
CHAPTER 1 An Overview of Computers and Programming

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"

REVIEW QUESTIONS test b. hard disk d. memory f. wordMedium > wordSmall


g. wordSmall = "TOY"
7. Which of the following pairs of steps in the programming process is in the
student comprehension of the correct order?
h. numberBig <= 5 * numberMedium 1 50
i. numberBig >= 2000
major ideas and techniques a. code the program, plan the logic
b. test the program, translate it into machine language
j. numberBig > numberMedium + numberSmall
k. numberBig > numberMedium AND numberBig < numberSmall
presented. Twenty questions c. put the program into production, understand the problem l. numberBig = 100 OR numberBig > numberSmall
d. code the program, translate it into machine language m. numberBig < 10 OR numberSmall > 10
follow each chapter. n. numberBig = 300 AND numberMedium = 10 OR numberSmall = 1
o. wordSmall > wordBig
p. wordSmall > wordMedium
2. Design a flowchart or pseudocode for a program that accepts two numbers from
a user and displays one of the following messages: First is larger, Second is larger,
Numbers are equal.
C9275_Chapter01_hr.indd 32 11/25/16 6:08 PM

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.

4. Cecilia’s Boutique wants several lists of salesperson data. Design a flowchart or


pseudocode for the following:
a. A program that accepts one salesperson’s ID number, number of items sold
in the last month, and total value of the items and displays data message only
if the salesperson is a high performer—defined as a person who sells more
than 200 items in the month.
b. A program that accepts the salesperson’s data and displays a message only if
the salesperson is a high performer—defined a person who sells more than
200 items worth at least $1,000 in the month.

C9275_Chapter04_hr.indd 170 11/25/16 6:17 PM


 ASSESSMENT

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.

Find the Bugs

1. Your downloadable files for Chapter 2 include DEBUG02-01.txt, DEBUG02-02.


txt, and DEBUG02-03.txt. Each file starts with some comments that describe
the problem. Comments are lines that begin with two slashes (//). Following the
comments, each file contains pseudocode that has one or more bugs you must
find and correct.

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

GAME ZONE EXERCISES are included


C9275_Chapter02_hr.indd 85
at the end of each chapter. Students can
11/25/16 6:22 PM

create games as an additional entertaining


way to understand key programming
DEBUGGING EXERCISES are concepts.
included with each chapter because
examining programs critically and
closely is a crucial programming skill.
Students can download these exercises
at www.cengagebrain.com and through
MindTap. These files are also available
to instructors through sso.cengage.com.
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Notes taken
during travels in Africa
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: Notes taken during travels in Africa

Author: John Davidson

Release date: September 1, 2023 [eBook #71535]

Language: English

Original publication: United Kingdom: J. L. Cox and Sons, 1839

Credits: Galo Flordelis (This file was produced from images


generously made available by The Internet
Archive/American Libraries/British Library)

*** START OF THE PROJECT GUTENBERG EBOOK NOTES


TAKEN DURING TRAVELS IN AFRICA ***
N O T E S

TAKEN DURING

T R A V E L S I N A F R I C A.
t
Drawn by J. G. Wilkinson Esqre. from a Sketch taken Drawn on Stone & Printed by P. Gauci, 9, North Cres .
by the late John Davidson. re
Bedford Sq .

VIEW OF WADNOON.
From the roof of Sheik Beyrook’s House
NOTES
TAKEN DURING

T R A V E L S I N A F R I C A,
BY THE LATE

JOHN DAVIDSON, F.R.S. F.S.A., &c.

PRINTED FOR PRIVATE CIRCULATION ONLY.

LONDON:
P R I N T E D B Y J . L . C O X A N D S O N S , 7 5 , G R E AT Q U E E N S T R E E T,
LINCOLN’S-INN FIELDS.

1839.
A D V E R T I S E M E N T.

To gratify the earnest desire expressed by the Friends of the late


Mr. Davidson to possess some memorial of him, his Brother has
been induced to print, for private distribution merely, the following
pages, drawn up from his MS. Journal.
It will be seen that they are only rough and brief notes penned at
the moment, and under circumstances the most trying to an active
mind, and with a presentiment of failure, which has been too truly
realized.
For the generally correct manner in which the names of persons
and places are here given, and which in the MS. were decyphered
with difficulty, Mr. Davidson’s Brother has to offer his best thanks to
the Rev. G. Renouard and Capt. Washington, of the Royal
Geographical Society of London.
C O N T E N T S.

Page

Mr. Davidson’s Notes, kept in the form of a Journal 1


Loose Memoranda found amongst Mr. Davidson’s Papers 165
Letters from Captain Washington to Mr. Davidson 168
Mr. Davidson’s Replies to Queries 175
Extracts from Mr. Davidson’s Letters 176

A P P E N D I X.
Extracts from the Correspondence of Mr. Davidson, during his Residence
in Morocco; with an Account of his further progress in the Desert 181
Account of Mr. Davidson’s Death, extracted from the Journal of the Royal
Geographical Society 202
History of Abou, extracted from the Journal of the Royal Geographical
Society 208
Mr. Hay’s Letter, referred to in the Notes, and Reply thereto 215

[Illustrations]
VIEW OF WADNOON.
Style of Buildings of Wadnoon.
THE RIVER DRAHA.
N O T E S

TAKEN DURING

T R A V E L S I N A F R I C A.

On Saturday, August 29, 1835, we left London by the mail, and


arrived the morning following at Exeter, where we went to the
cathedral, which Abou called one of the bishops’ churches. We
proceeded the same evening to Falmouth, which we reached on
Monday 31st. During the journey, Abou’s remarks were highly
creditable to him; he expressed himself quite astonished at the rate
of travelling, which he had ascertained by comparing the mile-stones
we had passed with the time, as indicated by a watch; nor was he
less struck with the quickness of changing horses, the punctuality in
the arrival of the mail, and the manner in which one bag is delivered,
and another received, while the coach is going on. In the whole
country, he said very prettily, no place for more than a mile could be
seen without a settlement; all is productive: no misery. He wound up
his reflections with the words,—‘Good king! good people!—African
people all blind: not know their own good, else they would ask
Englishmen to come and teach them.’
On Tuesday, Sept. 1, I went with Abou to see the Castle, where
the officer on duty put some men through the manual and platoon
exercise, and light infantry movements, much to the amusement of
Abou, who was not less gratified with the feats of horsemanship
exhibited by a company that performed the same evening at the
theatre.
On Thursday, Sept. 3d, we went on board the Sarah Nigritia, and
got off at one P.M., with the wind a-head and a considerable swell,
which produced its usual effect upon many of the passengers, and
myself among the number, but poor Abou was the worst of all; during
the whole voyage he was absolutely wretched, and quite unable to
rally,—a rather bad omen of his power to bear up, should greater
difficulties present themselves on land.
On Monday, Sept. 7, we passed Cape Finisterre, running along
the shore in comparatively smooth water, but with a heavy swell; and
on the 9th we made Cape St. Vincent, and saw, at six P.M. on the
morning following, Cadiz rising from the dark blue wave; and at half-
past seven anchored in the bay. Some time before the boat came off
to give us pratique I had gone ashore with Abou. After a good
breakfast at the Posada Inglaterra, I proceeded to the Franciscan
convent and chapel, and from thence to the cathedral. The last is a
very beautiful building, but rather too gaudy, and in not the best taste
of architecture. I returned to an omelette and a segar, and water and
rien de plus; strolled afterwards through the town, celebrated alike
for mostachas and mantillas, for playful fans, bronze faces, and
pretty feet.
At one P.M., we were on board again for Gibraltar. Towards Seville
there is a fine view of mountain scenery. But the country itself is in a
wretched state, the natural consequence of the numerous
revolutions it has been its fate to undergo, and where each province
not only declares itself independent of the government, but of one
another. How all this is to end, heaven only knows.
At ten P.M., we were called from the dinner-table by hearing that a
brig had been capsized. Went on deck, and found the report to be
too true. We sent our boats and took off some of the crew, and after
crossing Trafalgar Bay, reached Gibraltar at a quarter past ten.
Friday, Sept. 11.—I went to the library, club, and court. All things
seem to work well; but I much fear that I shall have some trouble
about Abou: he has been made too much of; the Moors are all on the
alert respecting him. I must beware of the French, too, for I foresee
they will be intriguing against me. While some of our party are gone
to visit the rock and the galleries, I am confined to my room on
matters of business, which is not quite so pleasant a way of passing
one’s time, although my window overlooks the bay of Algesiras,—a
view that would form not a bad subject for a panorama.
Saturday, Sept. 12.—The Governor, Sir A. Woodford, sent Col.
Fuller early to take me over the galleries, &c. Much as I had heard of
them, they surpassed all my expectations. On my return, I received a
visit from Sadi Abdallah, who wanted to take me to his house, and
made the offer of his best services, which, I suspect, will exceed all
the official ones. From him I heard that the king of Timbuctoo had
gone on a pilgrimage to Mecca, taking Gibraltar in his way; so that I
hope he may be returning to his capital when I am going thither.
What a fortunate thing it would be if I could get the appointment of
his Majesty’s hakeem (physician). Mr. Hay likewise paid me a visit:
he is the British Consul at Tangier. As the subjects discussed during
the interview were of an official and confidential nature, I cannot
disclose them. I fear, however, that I am not to expect much
assistance from him, although his offers are very kind. There is
evidently something wrong on the other side of the Straits. I shall be
guided rather by the intelligence and advice I receive from Benoliel,
[1] whom I am to meet again to-day at the Governor’s, whose
kindness and urbanity I shall never forget.
The weather is very hot, although the wind is easterly. The
vessels of war sailed this morning for Cadiz. Spain is in a sad state.
After dinner I went to St. Nicholas’ Cave. It was lighted up with blue
lights. The band, the company, the soldiers, all added to the natural
grandeur of the scene. The more I see of this place, the more I am
delighted with it.
Sunday, Sept. 13.—The air much cooler. Staid at home and read
the psalms and lessons. Mr. Hay called, and, after a long conference
with him, I felt still disposed to adhere to my original resolution, of
being guided rather by Benoliel. Towards evening the wind got up,
and at night increased to a gale. The dust was dreadful. A Sunday at
Gibraltar is more remarkable than at any other place. Jews, Turks,
Moors, Protestants, and Catholics, all keep it in their own way, and
each in a different one.
Monday, Sept. 14.—The wind still very high, and the dust quite
distressing. I waited on the Governor as soon as he came from the
convent, and afterwards visited Benoliel. His Excellency
recommended my going, and he was backed by Benoliel, but
opposed by Mr. Hay.[2] Dined again at the Governor’s, where I met
his chaplain, Dr. Burrows, a gentleman of great learning.
Tuesday, Sept. 15.—Started early for the market. This is a curious
and interesting scene. Moors, Jews, Spaniards, and lizards in
abundance are to be found there, together with a few Englishmen. I
met there with a Mr. Hodgson from Virginia: he is a fine specimen, I
calculate, of an United States’ diplomatist, and the most gentleman-
like American I have ever seen. I have written to Mr. Hay, to request
he will make arrangements for my departure; let us see what the
result will be.
Wednesday, Sept. 16.—Mr. Hodgson improves much upon
acquaintance. He is going to Morocco, and I shall lose a fine chance
should I not be able to get off with him. Everybody says the detention
is too bad, and it perfectly unhinges me. The air is much cooler,
although the thermometer is still at 75°. I received a long dispatch
from Mr. Hay, which ended by his stating that he would write on
Friday.
Thursday, Sept. 17.—Talked over matters with Mr. Hay, which are
more satisfactory than I anticipated. Visited Benoliel, who is still
disposed to assist me. Heard from him, that the son of the king of
Jemma was here, on his return from Mecca, and I am not without
hopes of being able to go with him. Walked out to the neutral ground;
looked at the stock and slaughter-houses, and did some shopping.
Feasted my eyes with a view of the blue Mediterranean, and the fine
line of the mountains of Spain, as seen from the eastern side of the
rock.
Friday, Sept. 18.—Went out to breakfast with Capt. Sheriff, and
took Abou with me. The spot where he lives is very beautiful. There
is a large garden, in which almost every variety of plants and fruits is
to be found. He shewed me the use of Kater’s circle, and offered me
his own instrument; but I fear I shall make a sorry hand at it. Visited
Dr. Burrows, and accompanied him to the library: it contains a good
selection of books. I ran my eyes over some travels in Africa.
Saturday, Sept. 19.—The air much cooler. Paraded the town, and
passed the afternoon in the library. Begin to feel tired of the place;
and as I have to remain here a fortnight longer, I know not how I
shall get through it. I am at little expense, except for coach-hire; but
this makes invitations rather expensive. Hagee Assalam came with a
dress for Abou; but it did not please me, besides it was far too dear; I
have, therefore, ordered one from Tetuan. The musquitos are a real
plague.
Sunday, Sept. 20. Went to the ‘Ecclesia Nova,’ and heard, as well
as I could do in a building ill-suited for hearing, an excellent sermon
from Dr. Burrows.
Sunday, Sept. 27.—[The journal of the week, from the 20th to the
27th, contains only an account of dinner parties; and though Mr. D.
complains of dyspeptic and dysenteric symptoms, he was sufficiently
recovered to go to church on the 27th.]
Monday, Sept. 28.—Walked to Alamada; afterwards attended the
opening of the session, when a true bill was found against a Mr.
Shervill, for dealing feloniously in slaves.
Tuesday, Sept. 29.—In the morning the weather was beautiful, but
at night it rained tremendously. Called on Benoliel, to know about the
presents [it would be necessary to take with me into Africa, for the
purpose of gaining the good-will of the native chiefs].
Wednesday, Sept. 30.—The rain came slick through the house,
and the weather was very cold.
Thursday, Oct. 1.—Attended the whole day, during which there
was a great deal of rain, at the trial of Mr. Shervill, who was
sentenced to an imprisonment for three years, and to hard labour.
[Upon the question of the slave trade, Mr. D. says that Abou gave his
opinion, but which side he took is not told.]
Monday, Oct. 5.—Ascended the rock. Went to the Signal-house,
and then to O’Hara’s Tower; saw the monkies; descended the
Mediterranean steps, and returned by St. Michael’s Cave.
Wednesday, Oct. 7.—Rode to Europa Point. Saw the Governor
upon the subject of a letter from Morocco.
Thursday, Oct. 8.—The feast of tabernacles. All the shops shut.
Saturday, Oct. 10.—Went with a party of thirteen to see the
convent in the Cork wood, and to Castillar. The last was once a fine
large and strong fortification, but is now in ruins. The scenery
magnificent. As we returned by the Bocca Leonie, it made our ride
about forty miles,—a pretty long excursion for a summer’s day.
Sunday, Oct. 11.—Three packets arrived from England;—as yet
no letters; hoped to receive some by the Governor’s bag. Went to St.
Roques’. Was disappointed.
Monday, Oct. 12.—Breakfasted at Major Rose’s, where I met Mr.
Woolfe, who had arrived by the packet from England. He lectured
afterwards in the Methodists’ chapel, and gave me a hit or two. As
young Mr. Hay is arrived I shall go next week. Received three letters
to-day. Heard a lecture at the library. The Jasseim sailed.[3]
Tuesday, Oct. 13.—Mr. Woolfe gave another lecture: it was nearly
a repetition of the former one. I feel most anxious to be off.
Friday, Oct. 16.—Heard bad news, which was, however, not
confirmed. [To what circumstance Mr. D. alludes, it is impossible to
glean from his journal.] Saw Benoliel, who was very kind; he brought
with him a lot of presents.
Monday, Oct. 19.—Attended the meeting at Dr. Burrows, and was
admitted the first honorary member of the Gibraltar Society.
Wednesday, Oct. 21.—Received a dispatch from Mr. Hay,
inclosing a letter from the Sultan. I shall have to go to Mogadore; but
I must not suffer such trifles to turn me aside from my purpose. I
shall prepare to start, if possible, on Monday next. Wrote to Tetuan
for Abou’s clothes. The Philosophical Meeting went off extremely
well to-day, and it is arranged for me to give a lecture before the
Governor and the Society on Friday next.
Friday, Oct. 23.—The lecture went off, I hope, pretty well.
Saturday, Oct. 24.—Passed the morning in receiving visits of
congratulation. I fear I am in for a second lecture, which, I suspect,
will prove a bore.
Thursday, Oct. 29.—Gave the second lecture, and then went to
St. Michael’s cave.
Friday, Oct. 30.—At length I have made up my mind to start for
Tangier. Saw Benoliel, and made some purchases.
Saturday, Oct. 31.—Began arranging the means of going to
Tetuan incog. with some fellow-travellers, who are to start the day
after to-morrow.
Monday, Nov. 2.—Went on board with the party, but the wind
blowing a gale from the East, caused the party to change their
destination. I now mean to go to Tangier.
Tuesday, Nov. 3.—The first meeting of the Philosophical Society
took place in the ball-room of the convent, and went off very well.
Thursday, Nov. 5.—A gale of wind, followed by rain, which comes
down here with a vengeance.
Sunday, Nov. 8.—The weather still boisterous; but, as the Jasseim
has arrived, I must now think of starting in good earnest.
Wednesday, Nov. 11.—Hazy and cold. Went round taking leave.
Hope to be off to-morrow, and to get on shore on Friday, which is
considered a lucky day amongst the Turks.
Thursday, Nov. 12.—Bought presents; packed up, and sailed at
twelve in the Jasseim. Met with baffling winds, and did not get in till
twelve P.M.
Friday, Nov. 13.—The weather cold. The gates shut. Went to Mr.
Hay’s, who was particularly kind; he has got me a beautiful Moorish
horse. We paid our first visit to the Governor, which was a very
satisfactory one.
Saturday, Nov. 14.—Got up early, and breakfasted with Mr. Hay.
The day cold but fine. We visited the castle and outskirts of the town
and prison. Saw the armour, the town fountains, and Socco.[4] After
lunch we went to the Kaid, to whom we made our presents, and
received in return mona—one sheep, twelve fowls, and one hundred
eggs; we then visited the tombs of the Sheiks, and returned by Vally.
Sunday, Nov. 15.—We intended to start for Tetuan at six A.M.; but
as usual, the first start is a jib. We got off, however, at seven. The
road was very heavy over a stiff clay. The first village we reached
was Marranna. It is situated upon a hill, but presented nothing to
interest us, except its numerous aloes, which were in full blossom;
we counted not less than sixty in a space not larger than Grosvenor-
square. The soil is very rich and the cattle are splendid. We then
passed on to Djedoéédi, through a most beautiful country, with every
variety of hill and dale, of mountain and valley, and of wood and
water. We took our meal at a well, and I contrasted the simple food
of the sturdy Moors—their thin bread, dates, and water, with our own
meat, eggs, and wine. In the neighbourhood are the ruins of a large
castle. After resting half-an-hour, we continued our journey through a
defile flanked by a wood, and having something like a road, near
which was a Fantasia,[5] which our kaid wanted us to see, and to
bivouack there: but this we declined to do, and pushed on to El Bab,
where, after frequent examination of our persons, and a lengthened
palaver, we were admitted. The whole city was gone to bed. After
groping our way, we reached at length the house of one Cohen, the
interpreter to the Consul, Mr. Butler, who, in a most polite manner,
got up to receive us. The thermometer at midnight stood at 40°, and
we felt the cold very sensibly.
Monday, Nov. 16.—We sent our letters to Mr. Solomon, and made
arrangements to visit the Báshá, a fine fat man, of the name of
Hashásh. Our reception was most flattering. Fifty soldiers, ten under
arms, together with his horses and a white mule saddled, were
turned out to salute us in the court-yard. He received us in his kiosk,
situated in a fine garden and enlivened by a fountain. He had a heap
of clothes of various hues before him. We were presented with tea
flavoured with ambergris, and other cups with verbenum in it, &c. &c.
There was likewise a mountain of dates, a Popocatepetl[6] of biscuit,
and an Ossa of sugared almonds. The tea was actually poisoned
with the quantity of sugar. We complimented him to his heart’s
content, and made our presents. He talked of his ladies “rárá,”[7]
and, after going over the palace, we went away much gratified. We
then paid a visit to Ersíní, the principal Moor of the place, whose
house is very beautiful, and afterwards went to Mr. Levy’s, which is
very comfortable, and saw the dresses and ornaments of his lady,
which were truly magnificent. We then paraded the town. It is a large
one, but, as usual, wretchedly dirty, and filled with dogs, &c. that act
the part of scavengers. Of the bázárs, the Algerine is the most
interesting, where we bought a few things, and, after dining, drank
tea with Mr. Levy. The town is well situated, is surrounded with
beautiful gardens, and protected by very respectable fortifications; its
population is about forty thousand, of which the Jews form a fourth
part.
Tuesday, Nov. 17.—We got up early, having felt very cold during
the night, when the thermometer was at 40°; received our present of
sheep, fowls, and eggs, which we sent to Mr. Butler, who would have
us dine with him. We then visited the gardens of the Sulṭán and of
the káïd, where we had a view of the country to the east; inspected
the excavations and the pot-making; we afterwards forded the river. I
cannot say I am fond of this fun. We then proceeded, through
dreadful roads, to the Marína, the port, and returned home too late to
see more of the town. After dining with Mr. Butler we took our leave,
much delighted: the civilities of Mr. Levy and Mr. Butler I shall never
forget. My expenses at this place were, one dollar a-day for bed and
board; one dollar a-day to the soldiers who escorted us about the
town and country; four to the one who took us from Tangier: two for
each of the mules; half-dollar a-day for the beasts required for the
promenade in the town and suburbs; two to the deputy-governor;
one to his favourite soldier; one to his master of the horse; half-dollar
to each of the negroes, and one peseta to each of the fifty soldiers.
Wednesday, Nov. 18.—Up at four A.M. Therm. 32°. A great deal of
ice. The cold of this winter is unusually severe. We did not get out of
the city till six. Halted at the same well as before. The journey
requires from ten to eleven hours. We got in at five P.M., when we
dined with Mr. Hay, who was exceedingly kind.
Thursday, Nov. 19.—The weather a little warmer, as the
thermometer has got up to 42°. This place may be called the garden
of the Tomans, the Ampelusian.[8] Dined with Mr. Hay, where I met
Mr. Hodgson. Although my letters have been despatched,
accompanied by one to the minister at Morocco, I must say, I have
little hopes of getting on.
Friday, Nov. 20.—Therm. 55°; much rain, and weather very
unpleasant. Received a visit from the Táleb Hasan, who is a learned
man. The letter sent to the Sulṭán was enveloped in a silk
handkerchief, and put into a tin case that cost two dollars; that to the
minister, with similar appendages, cost one dollar. I paid, likewise,
three dollars for the translation. On the day previous there was much
lightning, which continued through the night.
Saturday, Nov. 21.—The wind has veered round to the west. My
fellow-travellers think of returning. Not feeling very well, I have
employed the day in writing and receiving visits; afterwards I walked
out to the ruins of the old bridge. Paraded the town of Tangier, which
is no great things. I like Tetuan much better. I have been annoyed all
the day with the noise of a wedding celebrated after the fashion of
the country. Pipes of the most horrid kind, compared with which the
bagpipe is music itself, have an accompaniment of six drums; a calf
was killed at the door of the cage where the bride is kept, like a hen
in a coop. The noise of what they called singing continued through
the whole night.
Sunday, Nov. 22.—Up at daybreak; the weather delightful. Went
to see the party off. Every one wanting something, although the word
bahkshísh[9] was not heard; after much quarrelling and grumbling
they got to their boat, and we said adieu! Afterwards I went to the
church, where I heard a good sermon, but found the congregation
consisted of only two or three persons besides the family of the
Consul-general. Saw the game of powder[10] (la’b-el-báród) played,
myself on horseback and the Doctor[11] on foot. Fell in with the
procession of the marriage, the wild Ríf[12] and his long gun, the
bride in her cage. The dancing and howling of the party, the horses,
&c. &c. presented a most amusing, though somewhat fearful sight.
Amongst many slighter accidents they almost blew up my house. I
gave them some tea and sugar. During the revelry I saw many very
pretty girls, who were ready enough to shew their faces when the
Moors were not looking; many signs, too, were made, but to me they
were quite unintelligible. How these people contrive to keep up their
physical strength during two days and nights of continued exertion, I
cannot understand. At a little after midnight, a black slave proclaimed
that the bride was a virgin, in a manner that would frighten our
ladies. The announcement was received by vollies of musquetry. It is
now all over, and glad I am, as I shall get a little rest.
Monday, Nov. 23.—Therm. 60°. A brig has just arrived from
Alexandria with two hundred Hájís; I am going to see them pass the
officer of health. Such jumping, and such putting out of tongues here
and there, such beatings and misery on many a countenance, while
the contents of a living charnel-house are poured out. The báshá,
the sheïkh, and the beggar, are all upon an equality, and all looking
equally wretched. As the tide had flowed up while we were
inspecting these poor wretches, we got permission to pass through
the batteries, which are but poor things. They are mounted with guns
of every calibre and all kinds of metal; some are, however, very
beautiful. There are two fine mortars, and the beds for two others. I
walked out with Mr. Hay and the captain of the port, the Doctor, the
interpreter, Ibn Súr, and his highness the Sheïkh. The strong lines of
contrast which the scene presented afforded us no little amusement.
There have been more Hájís this year than were ever known. They
are allowed to pass free through the different countries, and are
permitted to carry with them an investment, up to three hundred
dollars; but for any sum beyond this a tax is levied, according to the
means of the party. The Jews are compelled to take off their slippers
when passing a street in which there is a mosque; they must not ride
an ass through this town; they are, however, the general merchants,
and act as interpreters. The Muëddins[13] here are a better class of
people than those who perform the same office in Egypt and Syria.
The fountain is pretty, but going to decay. The castle is weak, and its
whole appearance wretched. I purchased a dress, not a very
handsome one, but it was cheap. I got my háik for five dollars,

You might also like