Building Java Programs: A Back to Basics Approach Stuart Reges 2024 Scribd Download
Building Java Programs: A Back to Basics Approach Stuart Reges 2024 Scribd Download
com
https://textbookfull.com/product/building-java-programs-a-
back-to-basics-approach-stuart-reges/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/building-java-programs-a-back-to-
basics-approach-stuart-reges-2/
textboxfull.com
https://textbookfull.com/product/building-java-programs-a-back-to-
basics-approach-5th-edition-stuart-reges/
textboxfull.com
https://textbookfull.com/product/building-python-programs-1st-edition-
stuart-reges/
textboxfull.com
https://textbookfull.com/product/simpler-living-back-to-basics-
guides-2nd-edition-jeff-davidson/
textboxfull.com
College physics : a strategic approach 4th Edition Stuart
Field
https://textbookfull.com/product/college-physics-a-strategic-
approach-4th-edition-stuart-field/
textboxfull.com
https://textbookfull.com/product/artificial-intelligence-a-modern-
approach-4th-edition-stuart-russell/
textboxfull.com
https://textbookfull.com/product/back-trouble-a-new-approach-to-
prevention-and-recovery-based-on-the-alexander-technique-deborah-
caplan/
textboxfull.com
Building Java Programs
A Back to Basics Approach
Fourth Edition
Stuart Reges
University of Washington
Marty Stepp
Stanford University
The authors and publisher of this book have used their best efforts in
preparing this book. These efforts include the development, research, and
testing of the theories and programs to determine their effectiveness. The
authors and publisher make no warranty of any kind, expressed or implied,
with regard to these programs or to the documentation contained in this book.
The authors and publisher shall not be liable in any event for incidental or
consequential damages in connection with, or arising out of, the furnishing,
performance, or use of these programs.
Copyright © 2017, 2014 and 2011 Pearson Education, Inc. or its affiliates.
All rights reserved. Printed in the United States of America. This publication
is protected by copyright, and permission should be obtained from the
publisher prior to any prohibited reproduction, storage in a retrieval system,
or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise. For information regarding
permissions, request forms and the appropriate contacts within the Pearson
Education Global Rights & Permissions department, please visit
www.pearsonhighed.com/permissions/.
10 9 8 7 6 5 4 3 2 1
Introductory computer science courses are often seen as “killer” courses with
high failure rates. But as Douglas Adams says in The Hitchhiker's Guide to
the Galaxy, “Don't panic.” Students can master this material if they can learn
it gradually. Our textbook uses a layered approach to introduce new syntax
and concepts over multiple chapters.
Here are some of the changes that we have made in the fourth edition:
Since the publication of our third edition, Java 8 has been released. This new
version supports a style of programming known as functional programming
that is gaining in popularity because of its ability to simply express complex
algorithms that are more easily executed in parallel on machines with
multiple processors. ACM and IEEE have released new guidelines for
undergraduate computer science curricula, including a strong
recommendation to cover functional programming concepts.
We have added a new Chapter 19 that covers most of the functional concepts
from the new curriculum guidelines. The focus is on concepts, not on
language features. As a result, it provides an introduction to several new Java
8 constructs but not a comprehensive coverage of all new language features.
This provides flexibility to instructors since functional programming features
can be covered as an advanced independent topic, incorporated along the
way, or skipped entirely. Instructors can choose to start covering functional
constructs along with traditional constructs as early as Chapter 6. See the
dependency chart at the end of this section.
Case studies. We end most chapters with a significant case study that
shows students how to develop a complex program in stages and how to
test it as it is being developed. This structure allows us to demonstrate
each new programming construct in a rich context that can't be achieved
with short code examples. Several of the case studies were expanded
and improved in the second edition.
The following table shows how the layered approach works in the first six
chapters:
Control Programming
Chapter Data Input/Output
Flow Techniques
procedural
1 methods String literals println, print
decomposition
definite variables, local variables, class
2 loops expressions, constants,
(for) int, double pseudocode
console input, 2D
return
3 using objects parameters graphics
values
(optional)
conditional char pre/post conditions, printf
4
(if/else) throwing exceptions
indefinite
assertions, robust
5 loops boolean
programs
(while)
token/line-based file
6 Scanner file I/O
processing
Answers to all self-check problems appear on our web site and are accessible
to anyone. Our web site has the following additional resources for students:
Source code and data files for all case studies and other complete
program examples
Our web site has the following additional resources for teachers:
Closed lab creation tools to produce lab handouts with the instructor's
choice of problems integrated with the textbook
MyProgrammingLab
MyProgrammingLab is an online practice and assessment tool that helps
students fully grasp the logic, semantics, and syntax of programming.
Through practice exercises and immediate, personalized feedback,
MyProgrammingLab improves the programming competence of beginning
students who often struggle with basic concepts and paradigms of popular
high-level programming languages. A self-study and homework tool, the
MyProgrammingLab course consists of hundreds of small practice exercises
organized around the structure of this textbook. For students, the system
automatically detects errors in the logic and syntax of code submissions and
offers targeted hints that enable students to figure out what went wrong, and
why. For instructors, a comprehensive grade book tracks correct and
incorrect answers and stores the code inputted by students for review.
VideoNotes
Roughly 3–4 videos are posted for each chapter. An icon in the margin of the
page indicates when a VideoNote is available for a given topic. In each video,
we spend 5–15 minutes walking through a particular concept or problem,
talking about the challenges and methods necessary to solve it. These videos
make a good supplement to the instruction given in lecture classes and in the
textbook. Your new copy of the textbook has an access code that will allow
you to view the videos.
Acknowledgments
First, we would like to thank the many colleagues, students, and teaching
assistants who have used and commented on early drafts of this text. We
could not have written this book without their input. Special thanks go to
Hélène Martin, who pored over early versions of our first edition chapters to
find errors and to identify rough patches that needed work. We would also
like to thank instructor Benson Limketkai for spending many hours
performing a technical proofread of the second edition.
Second, we would like to thank the talented pool of reviewers who guided us
in the process of creating this textbook:
Finally, we would like to thank the great staff at Pearson who helped produce
the book. Michelle Brown, Jeff Holcomb, Maurene Goo, Patty Mahtani,
Nancy Kotary, and Kathleen Kenny did great work preparing the first edition.
Our copy editors and the staff of Aptara Corp, including Heather Sisan, Brian
Baker, Brendan Short, and Rachel Head, caught many errors and improved
the quality of the writing. Marilyn Lloyd and Chelsea Bell served well as
project manager and editorial assistant respectively on prior editions. For
their help with the third edition we would like to thank Kayla Smith-Tarbox,
Production Project Manager, and Jenah Blitz-Stoehr, Computer Science
Editorial Assistant. Mohinder Singh and the staff at Aptara, Inc., were also
very helpful in the final production of the third edition. For their great work
on production of the fourth edition, we thank Louise Capulli and the staff of
Lakeside Editorial Services, along with Carole Snyder at Pearson. Special
thanks go to our lead editor at Pearson, Matt Goldstein, who has believed in
the concept of our book from day one. We couldn't have finished this job
without all of their hard work and support.
Stuart Reges
Marty Stepp
Break through
To Improving results
MyProgammingLab™
Through the power of practice and immediate personalized feedback,
MyProgrammingLab helps improve your students' performance.
Programming Practice
With MyProgrammingLab, your students will gain firs-hand programming
experience in an interactive online environment.
Graduated Complexity
MyProgrammingLab breaks down programming concepts into short,
understandable sequences of exercises. Within each sequence the level and
sophistication of the exercises increase gradually but steadily.
Dynamic Roster
Students' submissions are stored in a roster that indicates whether the
submission is correct, how many attempts were made, and the actual code
submissions from each attempt.
Pearson eText
The Pearson eText gives students access to their textbook anytime, anywhere
www.pearsonhighered.com/cs-resources
1. Why Programming? 2
5. Why Java? 7
2. System.out.println 15
3. Escape Sequences 15
1. Syntax Errors 24
2. Logic Errors (Bugs) 28
1. Static Methods 31
2. Flow of Control 34
1. Structured Version 41
1. Primitive Types 64
2. Expressions 65
3. Literals 67
4. Arithmetic Operators 68
5. Precedence 70
2. 2.2 Variables 74
1. Assignment/Declaration Variations 79
2. String Concatenation 82
3. Increment/Decrement Operators 84
1. Scope 99
2. Pseudocode 105
1. DrawingPanel 197
3. Colors 203
4. System.out.printf 269
3. Simulations 324
* * * * *
“I shall be back in the evening,” Madame Guibert had said to her
daughter, as she got into Trélaz’s carriage. She was going to Chambéry
on family business. With the help of Étienne and François, who had
been lucky in their enterprises at Tonkin, and with Marcel’s aid during
the Sahara Expedition they had been able to keep Le Maupas.
At sunset Paule came out for the first time to lean on the
balustrade. She listened for the sound of the approaching carriage
coming up the slope, but she listened in the quiet evening air in vain.
As the frost was very sharp she ran to get a shawl, wrapped herself in
it, and waited.
The snow-covered land grew rosy in the evening light. A kind of
virginal purity was over it. The vine-branches and the hedges were
covered with a fine lacework of hoarfrost, which shone in the dying
fires of day. The bare woods had no more secrets, and the branches
with their thousand twigs stood out in the clear air like blades of grass.
Paule, who clung to this little place with every fibre of her being,
loved the fairy-like winter effects. The cold made her shiver. As she
crossed the threshold, a raven flew croaking across the horizon. Its
wings made a black spot against the pale sky.
“Bird of misfortune!” murmured the girl carelessly, without reading
any ill omen in it. Was it not the time for ravens? They hover over the
bare fields, near the houses, trying to find a scanty sustenance.
She put two logs in the drawing-room grate, built up the fire
carefully, and placed a kettle on the logs. Then she went to find a
glass, a spoon, the sugar and the bottle of rum, which she arrayed on
a little table near the fireplace. “Mother will be cold when she gets
back,” she thought during these preparations. “It is freezing to-night
and she will be dreadfully cold in that open cart of Trélaz’s. A good fire
and a hot drink will do her good. Poor Mother!”
She sat down beside the lamp and tried to read a book she had
begun. But this occupation could not hold her attention. She looked at
the clock. It was past six.
Uneasily she took up the shawl which she had left on a chair, and
went back to the veranda. Night had fallen. The stars were trembling in
the sky, as if they were cold. Although the moon was still invisible, the
horizon was not dark. It seemed as if a faint light was rising from
below, as if the white earth illumined the sky. Down in the depths of
the valley Paule saw the lamps of Chambéry shining. She looked
searchingly at the wood with its bare oak-trees, through which the
carriage must come, she watched for the light of the moving lamps,
and listened for the slightest sounds that the breeze carried to her. For
a moment the clatter of a mill deceived her. A shrill scream which broke
the silence made her shudder,—it was so like a cry of despair. When
she had recovered from her fright, she recognised the siren of a
neighboring factory. For a long time she remained leaning on the
balustrade, listening and receptive of every impression.
Marie, the old servant who had lived with the family through good
and bad fortune, came to look for her and scolded her.
“Now isn’t it madness to stay outside in this cold? Will you come in,
Miss Paule? You won’t bring Madame home any quicker by taking cold
yourself!”
Paule obeyed, making no reply. But she went no further than the
kitchen, so that she might be ready to run out at once. Hearing the
gate open, she rushed out and found herself face to face with a
peasant from Vimines, who on account of his poverty was ironically
nicknamed Baron.
“Oh!” she exclaimed in her disappointment, as the poor creature
walked unceremoniously into the kitchen.
“Good evening, everybody! I’ve just looked in as I passed, to get
warm.”
From time to time he did a day’s work at Le Maupas. He was an idle
good-for-nothing, whom Dr. Guibert had helped. He often came to the
door and asked for work, though really only to get a drink.
“Good evening, Baron. You did not meet my mother on the road?”
“No, Miss, I saw nobody.”
Seated near the stove with his felt hat crushed in his hand, he
looked at the girl and the servant with a cunning eye. Paule left them
and began gazing out once more into the night. The moon was
illuminating the scene with her silvery beams, but her light revealed
only the emptiness of the road.
In the kitchen the rustic was saying to Marie: “So you haven’t heard
anything?”
“About what?” asked the servant, putting her pan on the fire.
“About the news, bless you!”
“What news, you old chatterbox? What are you keeping to
yourself?”
Distrustful, he had thought that they were hiding it from him. At
last he understood that at Le Maupas they were still ignorant of what
all Cognin already knew. As he passed in front of the hospitable house,
he had yielded to his curiosity to see the effect of the bad news. But he
would not tell anything, not he! Everybody has his own job to do. He
quickly drained his glass of red wine, refused a second, and got up to
leave.
“Well, Baron, what about your news? Are you going to take it on to
Vimines?”
“That’s just it,” said he, winking his wicked eye.
“So you won’t tell us about it?”
“Oh, you will know it soon enough.”
“It’s all cry and no wool with you, you old humbug!”
On the threshold the rustic turned round and delivered himself of a
platitude with a sarcastic smile: “Live and learn! Well, well, what will
the old woman do?”
His feet falling lightly in the snow he passed behind Paule, who was
still leaning on the veranda rail.
“Good evening, miss. Bear up! You never know who’s alive or who’s
dead.”
The girl started again, more at this voice heard unexpectedly behind
her back than at the words, whose meaning she did not understand.
She came back to the kitchen with a vague fear mingled with her
uneasiness.
“Make us some nice soup, Marie, and very hot. It is freezing hard.”
And cheered by the cosy hearth she added, “That Baron almost
frightened me.”
The servant snorted. “A good-for-nothing like that, with a long
tongue! I don’t want to see him round here any more. Your father was
a good Samaritan when he picked up that fish. And he has the evil eye.
We must take care. If the soup is burned, it will be all his fault. I don’t
know what story he had heard in the town, but he had a long face and
was watching us as a cat watches a rat.”
The girl went back to the drawing-room to stir the fire. Now she
was alone, she no longer felt her accustomed courage. Her heart was
beating loudly in her breast. She tried to comfort herself and did not
succeed.
“Trélaz’s horse goes so slowly. That business at the lawyer’s always
lasts so much longer than one thinks it will....”
She could no longer keep down her anxiety, which increased every
minute. Even prayer could not calm her. As she was on her knees, she
heard the drawing-room door open.
“Is Mamma there?” she cried as she rose from her knees. It was old
Marie who appeared at the door.
“No, Miss Paule. It is a man who wants to speak to the mistress.”
“Who is he?”
“He says he is a policeman and has been sent by the Mayor.”
“A policeman! What does he want with us?”
As her mind recalled all the bad omens of that evening, the girl
trembled while she gave the order for the man to be shown in. But she
controlled herself and received the Mayor’s messenger with the
greatest outward calm.
Faroux, the policeman, was one of those silent, stolid countrymen
who give themselves up entirely to their work without ever thinking
about it. But in the presence of Paule Guibert it was impossible for him
not to understand at last the importance of his mission. As he came
along the road he had not given a thought to it. So many people
approach thus absent-mindedly the most sacred and most serious
tasks.
Standing before him the girl said:
“My mother is not at home. But could I not take her place?”
He stood there silent and stupid, and the pause increased Paule’s
secret fear. He stammered at last:
“Mademoiselle Guibert, I have come to ... to ... tell you ...”
In his face, as the lamp shone on it, she read so much confusion
and trouble that she gave way to her darkest presentiments. With a
few quick words she aroused the poor, frightened man from his stupor.
“Speak, oh, do speak! Has there been an accident? My mother ...
on the road....” She could not finish the sentence.
“No,” said the man, “I did not meet the lady.” And he relapsed into
silence.
“Well, why did you come? If you have anything to say, say it. Do be
quick!”
Straight and proud, she spoke in the commanding voice which she
knew how to take upon occasion, like Marcel. The stiffness of her
bearing quite confused the policeman, who drew the telegram from his
pocket and with his big trembling hand held it out to the girl. He tried
to take it back again, but the blue paper was already in Paule’s hand.
Before she had even opened it, she thought of her brother. She
glanced over it, said “Ah,” crushed up the telegram, and turned deadly
pale. But with a supreme effort she remained standing and did not cry.
She could not show her weakness to this man, whom she thought
unfeeling, but she had to lean on the table. This movement and her
pallor were her only admissions of weakness.
A fearful silence enveloped them. At last she was able to say
without trembling: “It is all right. You may go. I thank you.”
As he was stepping out she remembered the laws of rural
hospitality and added:
“Tell Marie to give you something to drink, please.”
But the policeman rushed through the kitchen and fled as if he had
murdered someone.
“Oh, my God!” cried Paule when no one could hear her. She
dragged herself towards the fireplace, held on to it for a minute with
her two hands, tried to stand, but had to drop into an armchair. Her
body shook from head to foot. She held her hand before her dry,
staring eyes to keep away the horrible vision before them. She saw
there before her on the carpet her brother lying dead, his shattered
forehead with the lifeblood flowing from it. That grave face of his, so
melancholy and so proud, which had been the more so ever since
Alice’s refusal,—she saw it now, sightless, motionless and icy-cold, still
in death and beautiful! “Marcel, Marcel,” she called softly, and hid her
face in her hands. The tears refused to come to her relief. Her adored
brother, the pride of her life, was dead. Dead, she repeated ten, twenty
times before she could understand the horror of it. Dead, the hero of
Andriba, the conqueror of Rabah and the desert! At thirty-two, this life
of courage, of gallantry and self-sacrifice, had been cut off. Oh, how
little he had cared for life. For a long time he had despised it. Had not
the meeting with a shy little girl taken away his joy in it? And Paule
distractedly racked her memory for the pictures in which she had read
the signs of coming fate. There was that hesitating smile which she
had surprised on his lips the first night that he confessed his secret to
her. There was that movement of indifference as he listened to the
mournful warnings of the owls after his last interview with Alice. And
there was again that strange, quiet, almost disinterested discussion of
his future, as they sat there on the tree-trunk at the edge of the
Montcharvin wood, on the day of his departure from France. For years,
since that evening at La Chênaie, he had carried death in his eyes. He
had never again mentioned Alice’s name, never spoken of his love. But
he had lived on without any faith in life.... And in that dear face that
her ardent love called up in her memory, Paule saw a deep serenity,
unchangeable, eternal. Then she gave a great cry and knelt down,
weeping.
“Yes,” she thought, “you are at peace at last. Our love was not
sufficient for you. We loved you too much, Marcel. You do not know
how I loved you. I cannot speak: but my heart was full of you. Why
was I not chosen in your place? Of what use am I?”
A new fear, which she would not admit to herself in this terrible
hour, completed the distraction of her mind. Marcel was not alone at
Timmimun....
All at once she started up.
“And Mother! Mother is coming home!” She had forgotten her. And,
thanking God who had allowed her to break to her mother this
supreme sorrow, she mourned no longer for him who was sleeping his
last sleep, dead on the day of victory, in a conquered land; but instead
for her who was quietly coming home along the dark roads, travelling
all unsuspicious towards the precipice. Might not this last blow crush
the frail old life, overwhelmed already with its many trials?
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com