Java Programming Eigth Edition Joyce Farrell 2024 scribd download
Java Programming Eigth Edition Joyce Farrell 2024 scribd download
com
https://ebookmeta.com/product/java-programming-eigth-
edition-joyce-farrell/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/java-programming-mindtap-course-
list-10th-edition-joyce-farrell/
ebookmeta.com
https://ebookmeta.com/product/programming-logic-design-
comprehensive-9th-edition-joyce-farrell/
ebookmeta.com
https://ebookmeta.com/product/programming-logic-and-design-
comprehensive-9th-edition-joyce-farrell/
ebookmeta.com
https://ebookmeta.com/product/practical-cockroachdb-building-fault-
tolerant-distributed-sql-databases-1st-edition-rob-reid/
ebookmeta.com
Colon Cancer Diagnosis and Therapy Volume 2 2nd Edition
Ganji Purnachandra Nagaraju Dhananjay Shukla Naveen Kumar
Vishvakarma
https://ebookmeta.com/product/colon-cancer-diagnosis-and-therapy-
volume-2-2nd-edition-ganji-purnachandra-nagaraju-dhananjay-shukla-
naveen-kumar-vishvakarma/
ebookmeta.com
https://ebookmeta.com/product/socioeconomic-pragmatic-variation-
speech-acts-and-address-forms-in-context-1st-edition-larssyn-staley/
ebookmeta.com
https://ebookmeta.com/product/the-greycoast-pack-complete-
collection-1st-edition-jena-wade-lorelei-m-hart/
ebookmeta.com
https://ebookmeta.com/product/the-digital-selling-handbook-1st-
edition-bill-stinnett/
ebookmeta.com
https://ebookmeta.com/product/cancer-stem-cells-basic-concept-and-
therapeutic-implications-farhadul-islam/
ebookmeta.com
Illegal Immigrants Model Minorities The Cold War of
Chinese American Narrative 1st Edition Heidi Kim
https://ebookmeta.com/product/illegal-immigrants-model-minorities-the-
cold-war-of-chinese-american-narrative-1st-edition-heidi-kim/
ebookmeta.com
EIGHTHEDITION
JAVA PROGRAMMING
JOYCE FARRELL
Java Programming,
Eighth Edition
Joyce Farrell
WCN: 02-200-203
ISBN: 978-1-285-85691-9
Cengage Learning
Boston, MA 02210
USA
Print Number: 01
Brief Contents
CHAPTER 2
Using Data . . . . . . . . . . . . . . . . . . . . . 53
CHAPTER 3
. . . . . . . 119
CHAPTER 4
CHAPTER 5
CHAPTER 6
Looping . . . . . . . . . . . . . . . . . . . . . 301
CHAPTER 7
CHAPTER 8
Arrays . . . . . . . . . . . . . . . . . . . . . . 393
CHAPTER 9
CHAPTER 10
CHAPTER 12
CHAPTER 13
. . . . . . . . . . . . . . . 665
CHAPTER 14
. . . . . . . . 729
CHAPTER 15
CHAPTER 16
Graphics . . . . . . . . . . . . . . . . . . . . . 861
APPENDIX A
APPENDIX B
Data Representation
. . . . . . . . . . . . . . . 925
APPENDIX C
Formatting Output
. . . . . . . . . . . . . . . . 931
APPENDIX D
. . . . . . . . . . . 941
APPENDIX E
Javadoc . . . . . . . . . . . . . . . . . . . . . 949
Glossary
....................
957
Index . . . . . . . . . . . . . . . . . . . . . .
979
Contents
Preface . . . . . . . . . . . . . . . . . . xxi
CHAPTER 1
Programming Concepts . . . . . . . . . . . . . . . . . . 6
Procedural Programming . . . . . . . . . . . . . . . . . . 6
Object-Oriented Programming . . . . . . . . . . . . . . . . 6
Indent Style
. . . . . . . . . . . . . . . . . . . . . . . 18
. . . . . . 35
Finding Help . . . . . . . . . . . . . . . . . . . . . . . . 38
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . . 39
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . 41
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . 45
Review Questions . . . . . . . . . . . . . . . . . . . . . . 46
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 48
Programming Exercises . . . . . . . . . . . . . . . . . . 48
Debugging Exercises . . . . . . . . . . . . . . . . . . . 50
Game Zone . . . . . . . . . . . . . . . . . . . . . . . . 50
Case Problems . . . . . . . . . . . . . . . . . . . . . . 51
CHAPTER 2
Using Data . . . . . . . . . . . . . . . . . 53
Declaring Variables . . . . . . . . . . . . . . . . . . . . 55
Performing Arithmetic . . . . . . . . . . . . . . . . . . . . 93
in Floating-Point Numbers
. . . . . . . . . . . . . . . . 96
. . . . . . . . . . . . . . . . 102
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 106
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 114
CHAPTER 3
Parentheses . . . . . . . . . . . . . . . . . . . . . . 125
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 168
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 174
CHAPTER 4
Overloading Constructors
. . . . . . . . . . . . . . . . 201
. . . . . . . . . . . . . . . . . . . . 221
Composition . . . . . . . . . . . . . . . . . . . . . . 230
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 234
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 239
CHAPTER 5
. . . . . . . . . . . . . . 250
. . . . 254
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 289
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 294
CHAPTER 6
Looping
. . . . . . . . . . . . . . . . . 301
. . . . . . . . . . . . . . . . . . 303
Operators . . . . . . . . . . . . . . . . . . . . . . 334
Incrementing . . . . . . . . . . . . . . . . . . . . . 337
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 342
Other documents randomly have
different content
expected to reach the eastern coast of Asia by crossing the Atlantic,
that part of Asia was so wholly unknown to Europeans, that its
discovery by means of a transatlantic voyage would have enabled
the discoverer to take possession of it as a new continent; and it was
hence quite proper for Columbus to speak of discovering a new
world when he was really intending to discover the eastern half of
what we now call the Old world.
It is all very well to have a good opinion of one’s self, but
Columbus really did put what seems to unprejudiced people a
tremendous price upon his services. Not only did he demand one
tenth of whatever profits might be derived from his discoveries, but
he insisted that he should be made an admiral, and viceroy over
every country that he might discover. One of the committee justly
remarked that the proposed arrangement was one by which
Columbus had everything to gain and nothing to lose, and that if he
made no discoveries whatever he would still be a Spanish admiral,
and would outrank scores of deserving officers who had spent their
lives in the service of their country. Columbus thereupon modified his
terms by consenting to take only an eighth of the profits, and to
furnish one eighth of the expenses.
It so happened that some member of the committee knew that
one eighth was more, instead of less, than one tenth. We need not
wonder, therefore, that the committee reported that the terms
proposed were inadmissible. De Talavera told the Queen that he had
met with a good deal of “cheek” in his time, but the cheek of
Columbus was positively monumental, and that nature designed him
not for an explorer but for a life-insurance agent.
The result was that the Queen decided to have no more to do
with the affair, and Columbus, in a tremendous rage, climbed upon
his mule and rode out of Santa Fé, remarking that he wouldn’t
discover a continent for the Spanish monarchs if continents were as
thick as blackberries. He furthermore declared that he would go
straight to France and make a contract with the French king, and that
the Spaniards would never cease to regret their short-sighted
economy.
As the extremity of the Columbian mule vanished through the
city gate, Luis de St. Angel, treasurer of the Church funds of the
kingdom of Aragon, and the much-suffering Quintanella—who did
not believe that Columbus would really go to France, and were
convinced that the true way in which to be permanently rid of him
was to send him on his proposed expedition—hastened to the
palace, and told the monarchs that they were risking the loss of a
new continent because they were afraid to risk two ships and a
comparatively small sum of money, and because they hesitated to
give the title of Admiral to an explorer who, if he did not succeed,
would in all probability never return to Spain.
The Queen was much impressed by this straightforward
statement of facts, and admitted that she would like to employ
Columbus upon his own terms. The King, instead of saying,
“Certainly, my dear; do so, by all means!” began to speak of the
emptiness of the treasury and the necessity for economy. Of course
this made Isabella indignant, and she rose up and exclaimed, “I will
undertake the enterprise in behalf of Castile, and will raise the
money if I have to pawn my jewels.”
[Æt. 55–56; 1492]
ON the 12th of May, 1492, Columbus left Santa Fé for Palos, the
seaport from which his expedition was to sail. He left his small-boy,
Diego, behind him, as page to Prince Juan, the heir of Castile and
Aragon. Diego was the son of his lawful wife, and it is pleasant to
find that, in spite of this fact, Columbus still remembered him. His
favorite son was of course Fernando, who, with his mother, Beatrix,
seems to have been sent away to board in the country during
Columbus’s absence at sea.
As soon as he arrived at Palos, Columbus called on his worthy
friend the Prior, and on the next day the two went to the church of St.
George, where the royal order directing the authorities of Palos to
supply Columbus with two armed ships, and calling upon everybody
to furnish the expedition with all necessary aid, was read aloud by a
notary-public. The authorities, as well as the other inhabitants of
Palos, were naturally only too glad to do everything in their power to
hasten the departure of Columbus; but it was found extremely
difficult to procure ships or sailors for the expedition. The merchants
very justly said that, much as they might desire to have Columbus
drowned, they did not care to furnish ships at their own expense for
an enterprise in the interest of all classes of the community. The
sailors declared that they were ready to ship for any voyage which
might be mentioned, but that it was a little too much to ask them to
go to sea with Columbus as their captain, since he would
undoubtedly use his authority to compel them to listen to a daily
lecture on “Other Continents than Ours,” thus rendering their
situation far worse than that of ordinary slaves.
The King and Queen, learning of the failure of Columbus to
obtain ships and men, and fearing that he might return to court,
ordered the authorities of Palos to seize eligible vessels by force,
and to kidnap enough sailors to man them. This would probably have
provided Columbus with ships and men, had not the short-sighted
monarch appointed one Juan de Peñalosa to see that the order was
executed, and promised him two hundred maravedies a day until the
expedition should be ready. De Peñalosa was perhaps not the
intellectual equal of the average American office-holder, but he had
sense enough to appreciate his situation, and of course made up his
mind that it would take him all the rest of his natural life to see that
order carried out. Accordingly, he drew his pay with great vigor and
faithfulness, but could not find any ships which, in his opinion, were
fit to take part in the proposed expedition. The people soon
perceived the state of affairs, and despaired of ever witnessing the
departure of Columbus.
Doubtless De Peñalosa would have gone on for years failing to
find the necessary ships, had not two noble mariners resolved to
sacrifice themselves on the altar of their country. Martin Alonzo
Pinzon and Vincente Yanez Pinzon, his brother, were the two marine
patriots in question. They offered a ship and crew, and the
magistrates, emulating their patriotism, seized two other ships and
ordered them to be fitted for service.
These vessels were under one hundred tons’ burthen each, and
only one of them, the Santa Maria, was decked over. In model they
resembled the boats carved by small inland boys, and their rig would
have brought tears to the eyes of a modern sailor—provided, of
course, a way of bringing a modern sailor to Palos to inspect them
could have been devised. If we can put any faith in woodcuts, the
Santa Maria and her consorts were two-masted vessels carrying one
or two large square sails on each mast, and remotely resembling
dismasted brigs rigged with jury-masts by some passengers from
Indiana who had studied rigging and seamanship in Sunday-school
books. The pretence that those vessels could ever beat to windward
cannot be accepted for a moment. They must have been about as
fast and weatherly as a St. Lawrence “pin flat,” and in point of safety
and comfort they were even inferior to a Staten Island ferry-boat.
The Pinta was commanded by Martin Pinzon, and the Niña by
Vincente Pinzon. No less than four pilots were taken, though how
four pilots could have been equally divided among three ships
without subjecting at least one pilot to a subdivision that would have
seriously impaired his efficiency, can not readily be comprehended.
Indeed, no one has ever satisfactorily explained why Columbus
wanted pilots, when he intended to navigate utterly unknown seas. It
has been suggested that he had bound himself not to talk to an
intemperate extent to his officers or men, and that he laid in a supply
of private pilots purely for the purpose of talking to them. It is much
more probable that a law of compulsory pilotage existed at that time
in Spain,—for it was a dark and ignorant age,—and that, inasmuch
as Columbus would have had to pay the pilots whether he took them
with him or not, he thought he might as well accept their services.
Besides, he may have remembered that a vessel rarely runs
aground unless she is in charge of a pilot, and hence he may have
imagined that pilots possessed a peculiar skill in discovering
unexpected shores at unlooked-for moments, and might materially
help him in discovering a new continent by running the fleet aground
on its coast.
A royal notary was also sent with the expedition, so that if any
one should suddenly desire to swear or affirm, as the case might be,
it could be done legally. The three vessels carried ninety sailors, and
the entire expeditionary force consisted of one hundred and twenty
men.
The ship-carpenters and stevedores, doubtless at the instigation
of Peñalosa, made all the delay they possibly could, and at the last
moment a large number of sailors deserted. Other sailors were
procured, and finally everything was in readiness for the departure of
the fleet. On Friday the 3d of August, 1492, Columbus and his
officers and men confessed themselves and received the sacrament,
after which the expedition put to sea.
In spite of the knowledge that Columbus was actually leaving
Spain with a very slight prospect of ever returning, the departure of
the ships cast a gloom over Palos. The people felt that to sacrifice
one hundred and nineteen lives, with three valuable vessels, was a
heavy price to pay, even for permanently ridding Spain of the
devastating talker. Still, we are not told that they permitted sentiment
to overpower their patriotism, and they were probably sustained by
the reflection that it was better that one hundred and nineteen other
people should be drowned, than that they themselves should be
talked to death.
It is universally agreed that it is impossible not to admire the
courage displayed by Columbus and his associates. The ships of the
expedition were small and unseaworthy. They were not supplied with
ice-houses, hot water, electric bells, saloons amidships where the
motion is least perceptible, smoking and bath rooms, or any of the
various other devices by which the safety of modern steamships is
secured. The crew knew that they were bound to an unknown port,
and that if their vessels managed to reach it there was no certainty
that they would find any rum. Columbus had employed eighteen
years in convincing himself that if he once set sail he would
ultimately arrive somewhere; but now that he was finally afloat, his
faith must have wavered somewhat. As he was an excellent sailor,
he could not but have felt uncomfortable when he remembered that
he had set sail on Friday. However, he professed to be in the very
best of spirits, and no one can deny that he was as brave as he was
tedious.
On the third day out, the Pinta unshipped her rudder, and soon
after began to leak badly. Her commander made shift partially to
repair the disaster to the rudder, but Columbus determined to put
into the Canaries, and charter another vessel in her place. He knew
that he was then not far from the Canaries, although the pilots, either
because their minds were already weakening under the strain of
their commander’s conversation, or because they were ready to
contradict him at every possible opportunity, insisted that the islands
were a long way off. Columbus was right, and on the 9th of August
they reached the Canaries, where we may suppose the pilots were
permitted to go ashore and obtain a little rest.
For three weeks Columbus waited in hopes of finding an
available ship, but he was disappointed. The Pinta was therefore
repaired to some extent, and the Niña was provided with a new set
of sails. A report here reached Columbus that three Portuguese
men-of-war were on their way to capture him—doubtless on the
charge of having compassed the death of several Portuguese
subjects with violent and prolonged conversation. He therefore set
sail at once, and as he passed the volcano, which was then in a
state of eruption, the crews were so much alarmed that they were on
the point of mutiny. Columbus, however, made them a speech on the
origin, nature, and probable object of volcanoes, which soon reduced
them to the most abject state of exhaustion.
Nothing was seen of the Portuguese men-of-war, and it has
been supposed that some practical joker alarmed the Admiral by
filling his mind with visions of hostile ships, when the only
Portuguese men-of-war in that part of the Atlantic were the harmless
little jelly-fish popularly known by that imposing title.
It was the 6th day of September when the expedition left the
Canaries, but owing to a prolonged calm it was not until the 9th that
the last of the islands was lost sight of. We can imagine what the
devoted pilots must have suffered during those three days in which
Columbus had nothing to do but talk; but they were hardy men, and
they survived it. They remarked to one another that they could die
but once; that care had once killed a vague and legendary cat; and
in various other ways tried to reconcile themselves to their fate.
The crew on losing sight of land became, so we are told, utterly
cast down, as they reflected upon the uncertainty of ever again
seeing a Christian grog-shop, or joining with fair ladies in the
cheerful fandango. Mr. Irving says that “rugged seamen shed tears,
and some broke into loud lamentation,” and that Columbus
thereupon made them a long speech in order to reconcile them to
their lot. The probability is that Mr. Irving reversed the order of these
two events. If Columbus made a long speech to his crew, as he very
likely did, there is no doubt that they shed tears, and lamented
loudly.
Lest the crew should be alarmed at the distance they were
rapidly putting between themselves and the spirituous liquors of
Spain, Columbus now adopted the plan of daily falsifying his
reckoning. Thus if the fleet had sailed one hundred miles in any
given twenty-four hours, he would announce that the distance sailed
was only sixty miles. Meanwhile he kept a private log-book, in which
he set down the true courses and distances sailed. This system may
have answered its purpose, but had the fleet been wrecked, and had
the false and the true log-books both fallen into the hands of the
underwriters, Columbus would not have recovered a dollar of
insurance, and would probably have been indicted for forgery with
attempt to lie. The lawyer for the insurance company would have put
in evidence the two entries for, let us say, the 10th of September; the
one reading, “Wind E.S.E., light and variable; course W. by N.;
distance by observation since noon yesterday, 61 miles;” and the
other, or true entry, reading, “Wind E.S.E.; course W. by N.; distance
by observation since noon yesterday, 117 miles. At seven bells in the
morning watch, furled main-top-gallant sails, and put a single reef in
all three topsails. This day ends with a strong easterly gale.” With
such evidence as this, he would easily have proved that Columbus
was a desperate villain, who had wrecked his vessels solely to
swindle the insurance companies. Thus we see that dishonesty will
vitiate the best policy, provided the underwriters can prove it.
It was perhaps this same desire to lead his crew into the belief
that the voyage would not be very long, which led Columbus to insert
in the sailing directions given to the two Pinzons an order to heave-to
every night as soon as they should have sailed seven hundred
leagues west of the Canaries. He explained that unless this
precaution were taken they would be liable to run foul of China in the
night, in case the latter should not happen to have lights properly
displayed. This was very thoughtful, but there is no reason to think
that it deceived the Pinzons. They knew perfectly well that Columbus
had not the least idea of the distance across the Atlantic, and they
probably made remarks to one another in regard to the difficulty of
catching old birds with chaff, which the Admiral would not have
enjoyed had he heard them.
Thus cheerfully cheating his sailors, and conversing with his
pilots, Columbus entered upon his voyage. A great many meritorious
emotions are ascribed to him by his biographers, and perhaps he felt
several of them. We have, however, no evidence on this point, and
the probability is that he would not have expressed any feeling but
confidence in his success to any person. He had long wanted to sail
in quest of new continents, and his wish was now gratified. He ought
to have been contented, and it is quite possible that he was.
CHAPTER VI.
THE VOYAGE.