(eBook PDF) Introduction to Java Programming, Brief Version, Global Edition 11th Edition pdf download
(eBook PDF) Introduction to Java Programming, Brief Version, Global Edition 11th Edition pdf download
https://ebooksecure.com/product/ebook-pdf-introduction-to-java-
programming-brief-version-global-edition-11th-edition/
http://ebooksecure.com/product/ebook-pdf-introduction-to-java-
programming-and-data-structures-comprehensive-version-11th-
global-edition/
https://ebooksecure.com/download/introduction-to-java-
programming-comprehensive-version-ebook-pdf/
http://ebooksecure.com/product/ebook-pdf-introduction-to-java-
programming-and-data-structures-comprehensive-version-11/
http://ebooksecure.com/product/ebook-pdf-java-an-introduction-to-
problem-solving-and-programming-7th-edition/
(eBook PDF) Java: An Introduction to Problem Solving
and Programming 8th Edition
http://ebooksecure.com/product/ebook-pdf-java-an-introduction-to-
problem-solving-and-programming-8th-edition/
http://ebooksecure.com/product/ebook-pdf-introduction-to-
programming-with-java-a-problem-solving-approach-3rd-edition/
http://ebooksecure.com/product/ebook-pdf-java-how-to-program-
late-objects-global-edition-11th-edition/
http://ebooksecure.com/product/ebook-pdf-calculus-with-
applications-brief-version-11th-edition/
https://ebooksecure.com/download/theatre-brief-version-ebook-pdf/
6 Preface
Part I: Fundamentals of Part II: Object-Oriented Part III: GUI Programming
Programming Programming
Chapter 1 Introduction to Chapter 9 Objects and Classes Chapter 14 JavaFX Basics
Computers, Programs, and
Java
Chapter 10 Thinking in Objects Chapter 15 Event-Driven
Programming and
Chapter 2 Elementary Animations
Chapter 11 Inheritance and
Programming
Polymorphism
Chapter 16 JavaFX Controls
Chapter 3 Selections and Multimedia
Chapter 12 Exception
Handling and Text I/O
Chapter 4 Mathematical
Functions, Characters, Chapter 13 Abstract Classes
and Strings and Interfaces
Chapter 6 Methods
Chapter 7 Single-Dimensional
Arrays
Chapter 8 Multidimensional
Arrays
Chapter 18 Recursion
Appendixes
This part of the book covers a mixed bag of topics. Appendix A lists Java keywords.
Appendix B gives tables of ASCII characters and their associated codes in decimal and in
hex. Appendix C shows the operator precedence. Appendix D summarizes Java modifiers and
their usage. Appendix E discusses special floating-point values. Appendix F introduces num-
ber systems and conversions among binary, decimal, and hex numbers. Finally, Appendix G
introduces bitwise operations. Appendix H introduces regular expressions. Appendix I covers
enumerated types.
Student Resources
The Companion Website (www.pearsonglobaleditions.com/Liang) contains the following
resources:
■■ Answers to CheckPoint questions
■■ Solutions to majority of even-numbered programming exercises
■■ Source code for the examples in the book
■■ Interactive quiz (organized by sections for each chapter)
■■ Supplements
■■ Debugging tips
■■ Video notes
■■ Algorithm animations
8 Preface
Supplements
The text covers the essential subjects. The supplements extend the text to introduce additional
topics that might be of interest to readers. The supplements are available from the Companion
Website.
Instructor Resources
The Companion Website, accessible from www.pearsonglobaleditions.com/Liang, c ontains the
following resources:
■■ Microsoft PowerPoint slides with interactive buttons to view full-color, syntax-highlighted
source code and to run programs without leaving the slides.
■■ Solutions to a majority of odd-numbered programming exercises.
■■ More than 200 additional programming exercises and 300 quizzes organized by chapters.
These exercises and quizzes are available only to the instructors. Solutions to these
exercises and quizzes are provided.
■■ Web-based quiz generator. (Instructors can choose chapters to generate quizzes from a
large database of more than two thousand questions.)
■■ Sample exams. Most exams have four parts:
■■ Multiple-choice questions or short-answer questions
■■ Correct programming errors
■■ Trace programs
■■ Write programs
■■ Sample exams with ABET course assessment.
■■ Projects. In general, each project gives a description and asks students to analyze, design,
and implement the project.
Some readers have requested the materials from the Instructor Resource Center. Please
understand that these are for instructors only. Such requests will not be answered.
Video Notes
We are excited about the new Video Notes feature that is found in this new edition. These VideoNote
videos provide additional help by presenting examples of key topics and showing how
to solve problems completely, from design through coding. Video Notes are available from
www.pearsonglobaleditions.com/Liang.
Algorithm Animations
We have provided numerous animations for algorithms. These are valuable pedagogical tools Animation
to demonstrate how algorithms work. Algorithm animations can be accessed from the Com-
panion Website.
10 Preface
Acknowledgments
I would like to thank Armstrong State University for enabling me to teach what I write and for
supporting me in writing what I teach. Teaching is the source of inspiration for continuing to
improve the book. I am grateful to the instructors and students who have offered comments,
suggestions, bug reports, and praise.
This book has been greatly enhanced thanks to outstanding reviews for this and previous
editions. The reviewers are: Elizabeth Adams (James Madison University), Syed Ahmed (North
Georgia College and State University), Omar Aldawud (Illinois Institute of Technology), Stefan
Andrei (Lamar University), Yang Ang (University of Wollongong, Australia), Kevin Bierre
(Rochester Institute of Technology), Aaron Braskin (Mira Costa High School), David Champion
(DeVry Institute), James Chegwidden (Tarrant County College), Anup Dargar (University of
North Dakota), Daryl Detrick (Warren Hills Regional High School), Charles Dierbach (Towson
University), Frank Ducrest (University of Louisiana at Lafayette), Erica Eddy (University of
Wisconsin at Parkside), Summer Ehresman (Center Grove High School), Deena Engel (New
York University), Henry A. Etlinger (Rochester Institute of Technology), James Ten Eyck
(Marist College), Myers Foreman (Lamar University), Olac Fuentes (University of Texas at
El Paso), Edward F. Gehringer (North Carolina State University), Harold Grossman (Clemson
University), Barbara Guillot (Louisiana State University), Stuart Hansen (University of Wis-
consin, Parkside), Dan Harvey (Southern Oregon University), Ron Hofman (Red River College,
Canada), Stephen Hughes (Roanoke College), Vladan Jovanovic (Georgia Southern University),
Deborah Kabura Kariuki (Stony Point High School), Edwin Kay (Lehigh University), Larry
King (University of Texas at Dallas), Nana Kofi (Langara College, Canada), George Koutsogi-
annakis (Illinois Institute of Technology), Roger Kraft (Purdue University at Calumet), Norman
Krumpe (Miami University), Hong Lin (DeVry Institute), Dan Lipsa (Armstrong State Univer-
sity), James Madison (Rensselaer Polytechnic Institute), Frank Malinowski (Darton College),
Tim Margush (University of Akron), Debbie Masada (Sun Microsystems), Blayne Mayfield
(Oklahoma State University), John McGrath (J.P. McGrath Consulting), Hugh McGuire (Grand
Valley State), Shyamal Mitra (University of Texas at Austin), Michel Mitri (James Madison
University), Kenrick Mock (University of Alaska Anchorage), Frank Murgolo (California State
University, Long Beach), Jun Ni (University of Iowa), Benjamin Nystuen (University of Colo-
rado at Colorado Springs), Maureen Opkins (CA State University, Long Beach), Gavin Osborne
(University of Saskatchewan), Kevin Parker (Idaho State University), Dale Parson (Kutztown
University), Mark Pendergast (Florida Gulf Coast University), Richard Povinelli (Marquette
University), Roger Priebe (University of Texas at Austin), Mary Ann Pumphrey (De Anza Junior
College), Pat Roth (Southern Polytechnic State University), Amr Sabry (Indiana University),
Ben Setzer (Kennesaw State University), Carolyn Schauble (Colorado State University), David
Scuse (University of Manitoba), Ashraf Shirani (San Jose State University), Daniel Spiegel
(Kutztown University), Joslyn A. Smith (Florida Atlantic University), Lixin Tao (Pace Uni-
versity), Ronald F. Taylor (Wright State University), Russ Tront (Simon Fraser University),
Deborah Trytten (University of Oklahoma), Michael Verdicchio (Citadel), Kent Vidrine (George
Washington University), and Bahram Zartoshty (California State University at Northridge).
It is a great pleasure, honor, and privilege to work with Pearson. I would like to thank Tracy
Johnson and her colleagues Marcia Horton, Demetrius Hall, Yvonne Vannatta, Kristy Alaura,
Carole Snyder, Scott Disanno, Bob Engelhardt, Shylaja Gattupalli, and their colleagues for
organizing, producing, and promoting this project.
As always, I am indebted to my wife, Samantha, for her love, support, and encouragement.
Preface 11
Chapter 3 Selections 97
3.1 Introduction 98
3.2 boolean Data Type 98
3.3 if Statements 100
3.4 Two-Way if-else Statements 102
3.5 Nested if and Multi-Way if-else Statements 103
3.6 Common Errors and Pitfalls 105
3.7 Generating Random Numbers 109
3.8 Case Study: Computing Body Mass Index 111
3.9 Case Study: Computing Taxes 112
3.10 Logical Operators 115
3.11 Case Study: Determining Leap Year 119
3.12 Case Study: Lottery 120
3.13 switch Statements 122
12
Contents 13
3.14 Conditional Operators 125
3.15 Operator Precedence and Associativity 126
3.16 Debugging 128
Appendixes 773
Appendix A Java Keywords 775
Appendix B The ASCII Character Set 776
Contents 17
19
20 VideoNotes
Understand property binding 570 Use Slider 690
Use Image and ImageView 578 Tic-Tac-Toe 693
Use layout panes 580 Use Media, MediaPlayer,
Use shapes 589 and MediaView 698
Display a tic-tac-toe board 608 Use radio buttons and text
Display a bar chart 610 fields 705
Set fonts 707
Chapter 15 Event-Driven Programming
and Animations 615 Chapter 17 Binary I/O 713
Handler and its registration 622 Copy file 726
Anonymous handler 625 Object I/O 728
Move message using the mouse 634 Split a large file 738
Animate a rising flag 640
Flashing text 646 Chapter 18 Recursion 741
Simple calculator 656 Binary search 752
Check mouse-point location 658 Directory size 753
Display a running fan 661 Fractal (Sierpinski triangle) 758
Search a string in a directory 769
Chapter 16 JavaFX UI Controls and Multimedia 665 Recursive tree 772
Use ListView 684
Animations
21
This page intentionally left blank
Chapter
1
Introduction
to Computers,
Programs, and Java™
Objectives
■■ To understand computer basics, programs, and operating systems
(§§1.2–1.4).
■■ To describe the relationship between Java and the World Wide Web
(§1.5).
■■ To understand the meaning of Java language specification, API, JDK™,
JRE™, and IDE (§1.6).
■■ To write a simple Java program (§1.7).
■■ To display output on the console (§1.7).
■■ To explain the basic syntax of a Java program (§1.7).
■■ To create, compile, and run Java programs (§1.8).
■■ To use sound Java programming style and document programs properly
(§1.9).
■■ To explain the differences between syntax errors, runtime errors, and
logic errors (§1.10).
■■ To develop Java programs using NetBeans™ (§1.11).
■■ To develop Java programs using Eclipse™ (§1.12).
Exploring the Variety of Random
Documents with Different Content
The Project Gutenberg eBook of The Siege and
Conquest of the North Pole
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.
Language: English
THE
BY
GEORGE BRYCE, L.R.C.P. & S. (Edin.)
LONDON
GIBBINGS & COMPANY LIMITED
18 BURY STREET, W.C.
1910
PREFACE
MAPS
INTRODUCTION
“There’s a flag on the mast, and it points to the north,
And the north holds the land that I love;
I will steer back to northward, the heavenly course
Of the winds guiding sure from above.”
Frithjof’s Saga.
The North Pole is the centre of the Northern Hemisphere. This
hemisphere contains Europe, Asia, North America, and a large part
of Africa, yet no human being reached its centre before the eighth
year of the twentieth century A.D.
The North Pole is the point where the axis of the earth cuts its
surface. It is the point where, as Captain Hall expressed it, there is
no north, no east, no west. It is the place where every wind that
blows is a south wind. It is a point where all the meridians meet,
and there is therefore no longitude. It is one of the two places on
the surface of the earth where there is but one night and one day in
every year. It is a point from which all the heavenly bodies appear to
move in horizontal courses, and the stars never set. It is not to be
confused with the magnetic pole, which is situated about 1600 miles
south of it, near the mainland of North America. At the North Pole
the magnetic needle points due south.
The North Pole is therefore a place of absorbing interest, and
until it was reached man never rested satisfied. Ever since Robert
Thorne, in the reign of Henry VIII., offered “very weighty and
substantial reasons to set forth a discoverie even to the North Pole,”
the struggle has been going on.
In no other records of adventure do we find greater deeds of
daring than in those of Arctic travel. The dauntless courage in the
face of extreme danger, the perseverance when hope was forlorn,
the self-sacrifices made to render assistance to comrades, all stamp
these pioneers of science and commerce as heroes in the highest
sense of the word. Some of their daring exploits, their successes and
disasters, are here recorded, but the author hopes that this book will
only serve as an introduction to the original ones. After reading the
thrilling narratives of Arctic exploration, one is ready to admit that
“truth is stranger than fiction.”
The Polar regions can be reached by only three navigable routes.
Either by the wide passage between Greenland and Norway, a
smaller passage between Greenland and America, or by the narrow
Bering Strait between America and Russia.
Up till the beginning of the nineteenth century nearly all the
Arctic voyages had as the chief object the discovery either of a
north-west or a north-east passage to the Pacific Ocean.
On the 7th June 1585 two tiny craft sailed from Dartmouth in
quest of the North-West Passage. They were commanded by John
Davis, a daring explorer.
Davis sighted Greenland on 20th July, and on the 29th he was off
where now stands the Danish settlement of Godthaab. He crossed
the strait which now bears his name, and traced part of the western
coast.
Davis made a second voyage in 1586, and a third in 1587. In the
latter year he reached and named Sanderson’s Hope, in 72° 41′.
Between 1594 and 1596 three expeditions were dispatched by
the Dutch towards Spitzbergen. That of 1596 is of special interest.
William Barents, the discoverer of Spitzbergen, was the chief pilot.
The ship reached Ice Haven, Novaya Zemlya, on 26th August, and
here the party were forced to winter. A house was built with wood,
but the winter was passed miserably, scurvy ultimately making its
appearance among the crew. The ship being hopelessly beset by the
ice, it was decided during the following summer to abandon it.
In two boats, the party of fifteen men started on a journey of
1524 miles. Barents himself and one of the crew were ill, and had to
be dragged on a sledge from the house to the boats. Both died on
the boat-journey. The remainder ultimately reached Russian Lapland,
where their troubles ceased.
About 274 years afterwards, the house built by Barents was
discovered by Captain Carlsen. Over the fireplace still stood the
cooking-pans, an old clock was against the wall, and arms, tools,
drinking-vessels, and books were found as they had been left nearly
three centuries before.
In 1607, Henry Hudson endeavoured to reach the Pole along the
east coast of Greenland. He attained 73° at a point which he named
“Hold with Hope.”
He then examined the edge of the ice between Greenland and
Spitzbergen, and reached the latitude of 80° 23′. He named the
north-west point of Spitzbergen “Hakluyt Headland,” and on his way
home he discovered the island now known as “Jan Mayen.”
In 1610 he discovered Hudson’s Strait, and the great bay which
bears his name.
On 26th March 1616, Robert Bylot as master, with William Baffin
as pilot and navigator, set out from Gravesend in the Discovery, a
craft of only 55 tons. Greenland was sighted on 14th May, and on
the 30th May, Sanderson’s Hope, the farthest point of Davis, was
reached. On the 9th June he discovered Baffin Islands, in 73° 54′.
He then took what is known as the “Middle Passage” across Melville
Bay, and reached the “North Water” of the whalers of to-day.
Baffin discovered and charted Wolstenholme Sound and Hakluyt
Island, and passed north till he was within sight of Cape Alexander.
He named Smith Sound after the first Governor of the East India
Company. He also discovered Carey Islands, Lancaster Sound, and
Jones Sound.
When we consider the wretched means with which these early
explorers were provided, we are lost in astonishment at their
audacity and at the success of their achievements.
It was exactly two hundred years afterwards that these northern
places were visited by Ross and Parry. Baffin’s work had been almost
forgotten, and his discoveries were not believed.
During the seventeenth century many expeditions were sent out
which were the means of opening up extensive commercial relations
with Russia and of establishing the fisheries of Spitzbergen, Davis
Straits, and Newfoundland.
During the eighteenth century several expeditions were fitted out
by the Hudson Bay Company, and a good deal of exploration was
done by the Russians. In 1728, Vitus Bering discovered the straits
which now bear his name; and in 1742, Lieutenant Chelyuskin
reached the most northerly point of Asia in 77° 34′ by sledges. In
1765, Admiral Tschitschagoff was sent by the Czarina Catharine of
Russia with three vessels to Spitzbergen to sail towards the North
Pole. He reached 80° 21′, but found it impossible to advance farther.
The following year he reached 80° 28′. In 1770 the New Siberian
Islands were discovered by Liakhof.
In 1773, Constantine John Phipps, afterwards Lord Mulgrave,
sailed with the Racehorse and Carcass, with a view of reaching the
North Pole. He reached 80° 37′, and visited some of the Seven
Islands. He also mapped the north of Spitzbergen. In this expedition
the great Horatio Nelson was captain’s coxswain on board the
Carcass.
In 1818, Captain Buchan in the Dorothea, and Lieutenant
(afterwards Sir John) Franklin in the Trent, attained 80° 34′ north of
Spitzbergen.
In 1823, Clavering and Sabine, in the ship Griper, visited
Spitzbergen, and while Sabine carried on magnetic observations on
the inner Norway Island, Clavering went to sea and steered
northwards, but did not get farther than 80° 20′.
The edge of the ice had now been thoroughly examined between
the coast of Greenland and Novaya Zemlya, and it became evident
that the ice could not be pierced by a ship. It occurred to Sir John
Franklin and Sir Edward Parry that the best way of reaching the Pole
would be by means of sledging over the ice. Parry put his ideas into
practice in 1827, when he undertook his well-known expedition in
the Hecla. He had just returned from his third Arctic voyage in
search of the North-West Passage. His fourth voyage was an
important one, and will be treated at some length in the first
chapter.
ebooksecure.com