(Ebook) Java(TM) Programming: From Problem Analysis to Program Design by D. S. Malik ISBN 9781111530532, 111153053X 2024 scribd download
(Ebook) Java(TM) Programming: From Problem Analysis to Program Design by D. S. Malik ISBN 9781111530532, 111153053X 2024 scribd download
https://ebooknice.com/product/java-programming-from-problem-analysis-
to-program-design-4130342
ebooknice.com
https://ebooknice.com/product/java-programming-from-problem-analysis-
to-program-design-4th-edition-2365278
ebooknice.com
https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-4334672
ebooknice.com
https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-7031230
ebooknice.com
(Ebook) C++ programming : from problem analysis to program design by D
S Malik ISBN 9781423902096, 1423902092
https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-4700604
ebooknice.com
https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-5th-2336846
ebooknice.com
https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-2444624
ebooknice.com
https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-4178294
ebooknice.com
https://ebooknice.com/product/c-programming-from-problem-analysis-to-
program-design-10810090
ebooknice.com
Java TM Programming From Problem Analysis to
Program Design 5th Edition D. S. Malik Digital Instant
Download
Author(s): D. S. Malik
ISBN(s): 9781111530532, 111153053X
Edition: 5
File Details: PDF, 3.43 MB
Year: 2011
Language: english
Licensed to: iChapters User
Licensed to: iChapters User
JAVA PROGRAMMING
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN
FIFTH EDITION
D.S. MALIK
Australia ! Brazil ! Japan ! Korea ! Mexico ! Singapore ! Spain ! United Kingdom ! United States
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
!"#$%&$$&'(&)*+),,-*.*/00111** "2323$11133456475189
Licensed to: iChapters User
Java Programming: From Problem Analysis ª 2012 Course Technology, Cengage Learning
to Program Design, Fifth Edition
ALL RIGHTS RESERVED. No part of this work covered by the
D.S. Malik copyright herein may be reproduced, transmitted, stored or used
Executive Editor: Marie Lee in any form or by any means graphic, electronic, or mechanical,
including but not limited to photocopying, recording, scanning,
Acquisitions Editor: Brandi Shailer digitizing, taping, Web distribution, information networks, or
Senior Product Manager: Alyssa Pratt information storage and retrieval systems, except as permitted
Editorial Assistant: Jacqueline Lacaire under Section 107 or 108 of the 1976 United States Copyright Act,
without the prior written permission of the publisher.
Content Project Manager: Lisa Weidenfeld
Associate Marketing Manager: Shanna For product information and technology assistance, contact us at
Shelton Cengage Learning Customer & Sales Support, 1-800-354-9706
Art Director: Faith Brosnan For permission to use material from this text or product, submit
all requests online at www.cengage.com/permissions
Proofreader: Andrea Schein
Further permissions questions can be emailed to
Indexer: Alexandra Nickerson permissionrequest@cengage.com
Print Buyer: Julio Esperas
Cover Designer: Roycroft Design/
www.roycroftdesign.com Library of Congress Control Number: 2010940363
Cover Photo: ª photolibrary/Richard ISBN-13: 978-1-111-53053-2
Cummins ISBN-10: 1-111-53053-x
Compositor: Integra Course Technology
20 Channel Center Street
Boston, MA 02210
Some of the product names and company
USA
names used in this book have been used for
identification purposes only and may be
trademarks or registered trademarks of their Cengage Learning is a leading provider of customized
respective manufacturers and sellers. learning solutions with office locations around the globe,
including Singapore, the United Kingdom, Australia, Mexico,
Any fictional data related to persons or
Brazil and Japan. Locate your local office at:
companies or URLs used throughout this
www.cengage.com/global
book is intended for instructional purposes
only. At the time this book was printed, any Cengage Learning products are represented in Canada by
such data was fictional and not belonging to Nelson Education, Ltd.
any real persons or companies.
To learn more about Course Technology, visit
Course Technology, a part of Cengage www.cengage.com/coursetechnology
Learning, reserves the right to revise this
Purchase any of our products at your local college store
publication and make changes from time to
or at our preferred online store www.cengagebrain.com
time in its content without notice.
The programs in this book are for
instructional purposes only. They have been
tested with care, but are not guaranteed for
any particular intent beyond educational
purposes. The author and the publisher do
not offer any warranties or representations,
nor do they accept any liabilities with respect
to the programs.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
TO
My Daughter
Shelly Malik
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
B RIEF C ONTENTS
PREFACE xix
1. An Overview of Computers and Programming Languages 1
9. Arrays 551
INDEX 1023
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
TABLE OF C ONTENTS
Preface xix
Language of a Computer 6
Programming Methodologies 19
Structured Programming 19
Object-Oriented Programming 19
Quick Review 21
Exercises 23
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Data Types 32
Primitive Data Types 32
Expressions 40
Mixed Expressions 41
class String 45
Strings and the Operator + 46
Input 48
Allocating Memory with Named Constants and Variables 48
Putting Data into Variables 51
Declaring and Initializing Variables 55
Input (Read) Statement 56
Reading a Single Character 61
Output 66
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
viii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Quick Review 94
Exercises 97
Input/Output 129
Formatting Output with printf 129
Using Dialog Boxes for Input/Output 139
Formatting the Output Using the String Method format 146
Exercises 167
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Table of Contents | ix
Exercises 232
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Exercises 306
Exercises 378
Table of Contents | xi
Exercises 445
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Finalizers 507
Exercises 538
ARRAYS 551
9 Why Do We Need Arrays? 552
Arrays 553
Alternate Ways to Declare an Array 555
Accessing Array Elements 555
Specifying Array Size during Program Execution 557
Array Initialization during Declaration 558
Arrays and the Instance Variable length 558
Processing One-Dimensional Arrays 559
Array Index Out of Bounds Exception 564
Declaring Arrays as Formal Parameters to Methods 564
Assignment Operator, Relational Operators, and Arrays:
A Precaution 565
Arrays as Parameters to Methods 567
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Exercises 623
Polymorphism 664
Operator instanceof 670
Interfaces 681
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Exercises 712
Exercises 777
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Table of Contents | xv
Menus 844
Exercises 866
RECURSION 873
13
Recursive Definitions 874
Direct and Indirect Recursion 876
Infinite Recursion 877
Designing Recursive Methods 877
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xvi | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Exercises 897
Exercises 934
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Chapter 2 998
Chapter 3 1001
Chapter 4 1002
Chapter 5 1004
Chapter 6 1007
Chapter 7 1008
Chapter 8 1010
Chapter 9 1014
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xviii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Chapter 10 1016
Chapter 11 1018
Chapter 12 1019
Chapter 13 1020
Chapter 14 1020
INDEX 1023
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Welcome to Java Programming: From Problem Analysis to Program Design, Fifth Edition.
Designed for a first Computer Science (CS1) Java course, this text will provide a breath of
fresh air to you and your students. The CS1 course serves as the cornerstone of the Computer
Science curriculum. My primary goal is to motivate and excite all programming students,
regardless of their level. Motivation breeds excitement for learning. Motivation and excite-
ment are critical factors that lead to the success of the programming student. This text is the
culmination and development of my classroom notes throughout more than fifty semesters of
teaching successful programming.
Warning: This text can be expected to create a serious reduction in the demand for program-
ming help during your office hours. Other side effects include significantly diminished student
dependency on others while learning to program.
The primary focus in writing this text is on student learning. Therefore, in addition to clear
explanations, we address the key issues that otherwise impede student learning. For example, a
common question that arises naturally during an early programming assignment is: ‘‘How
many variables and what kinds are needed in this program?’’ We illustrate this important and
crucial step by helping students learn why variables are needed and how data in a variable is
manipulated. Next students learn that the analysis of the problem will spill the number and
types of the variables. Once students grasp this key concept, control structures (selection and
loops) become easier to learn. The second major impediment in learning programming is
parameter passing. We pay special attention to this topic. First students learn how to use
predefined methods and how actual and formal parameters relate. Next students learn about
user-defined methods. They see visual diagrams that help them learn how methods are called
and how formal parameters affect actual parameters. Once students have a clear understanding
of these two key concepts, they readily assimilate advanced topics.
The topics are introduced at a pace that is conducive to learning. The writing style is friendly,
engaging, and straightforward. It parallels the learning style of the contemporary CS1 student.
Before introducing a key concept, the student learns why the concept is needed, and then sees
examples illustrating the concept. Special attention is paid to topics that are essential in
mastering the Java programming language and in acquiring a foundation for further study
of computer science.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Other important topics include debugging techniques and techniques for avoiding programming
bugs. When a beginner compiles his/her first program and sees that the number of errors exceeds the
length of this first program, he/she becomes frustrated by the plethora of errors, only some of which
can be interpreted. To ease this frustration and help students learn to produce correct programs,
debugging and bug avoidance techniques are presented systematically throughout the text.
Approach
Once conceived as a Web programming language, Java slowly but surely found its way into
classrooms where it now serves as a first programming language in computer science curricula
(CS1). Java is a combination of traditional style programming—programming with a non-
graphical user interface—and modern style programming with a graphical user interface
(GUI). This book introduces you to both styles of programming. After giving a brief
description of each chapter, we discuss how to read this book.
Chapter 1 briefly reviews the history of computers and programming languages. The reader
can quickly skim and become familiar with some of the hardware and software components of
the computer. This chapter also gives an example of a Java program and describes how a Java
program is processed. The two basic problem-solving techniques, structured programming
and object-oriented design, are also presented.
After completing Chapter 2, students become familiar with the basics of Java and are ready to
write programs that are complicated enough to do some computations. The debugging section
in this chapter illustrates how to interpret and correct syntax errors.
The three terms that you will encounter throughout the book are—primitive type variables,
reference variables, and objects. Chapter 3 makes clear distinctions between these terms and
sets the tone for the rest of the book. An object is a fundamental entity in an object-oriented
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
programming language. This chapter further explains how an object works. The class
String is one of the most important classes in Java. This chapter introduces this class and
explains how various methods of this class can be used to manipulate strings. Because input/
output is fundamental to any programming language, it is introduced early, and is covered in
detail in Chapter 3. The debugging section in this chapter illustrates how to find and correct
logical errors.
Chapters 4 and 5 introduce control structures used to alter the sequential flow of execution.
The debugging sections in these chapters discuss and illustrate logical errors associated with
selection and looping structures.
Java is equipped with powerful yet easy-to-use graphical user interface (GUI) components
to create user-friendly graphical programs. Chapter 6 introduces various GUI components
and gives examples of how to use these components in Java application programs. Because
Java is an object-oriented programming language, the second part of Chapter 6 discusses
and gives examples of how to solve various problems using object-oriented design
methodology.
Chapter 7 discusses user-defined methods. Parameter passing is a fundamental concept in any
programming language. Several examples, including visual diagrams, help readers understand
this concept. It is recommended that readers with no prior programming background spend
extra time on this concept. The debugging section in this chapter discuss how to debug a
program using stubs and drivers.
Chapter 8 discusses user-defined classes. In Java, a class is an important and widely used
element. It is used to create Java programs, group related operations, and it allows users to
create their own data types. This chapter uses extensive visual diagrams to illustrate how
objects of classes manipulate data.
Chapter 9 describes arrays. This chapter also introduces variable length formal parameter lists.
In addition, this chapter introduces foreach loops and explains how this loop can be used to
process the elements of an array. This chapter also discusses the sequential searching algorithm
and the class Vector.
Inheritance is an important principle of object-oriented design. It encourages code reuse.
Chapter 10 discusses inheritance and gives various examples to illustrate how classes are
derived from existing classes. In addition, this chapter also discusses polymorphism, abstract
classes, inner classes, and composition.
An occurrence of an undesirable situation that can be detected during program execution is
called an exception. For example, division by zero is an exception. Java provides extensive
support for handing exceptions. Chapter 11 shows how to handle exceptions in a program.
Chapter 11 also discusses event handling, which was introduced in Chapter 6. Chapter 12
picks up the discussion of GUI components started in Chapter 6. This chapter introduces
additional GUI components and discusses how to create applets.
Chapter 13 introduces recursion. Several examples illustrate how recursive methods
execute.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xxii | Java Programming: From Problem Analysis to Program Design, Fifth Edition
Chapter 14 discusses a binary search algorithm as well as bubble sort, selection sort, insertion
sort, and quick sort algorithms. Additional content covering the sorting algorithms bubble sort
and quick sort is provided online at www.cengagebrain.com.
Appendix A lists the reserved words in Java. Appendix B shows the precedence and
associativity of the Java operators. Appendix C lists the ASCII (American Standard Code
for Information Interchange) portion of the Unicode character set as well as the EBCDIC
(Extended Binary Code Decimal Interchange) character set.
Appendix D contains additional topics in Java. The topics covered are converting a base 10
number to binary (base 2) number and vice versa, converting a number from base 2 to base 8 (base
16) and vice versa, how to compile and execute a Java program using command line statements,
how to create Java style documentation of the user-defined classes, how to create packages, how to
use user-defined classes in a Java program, and enum type. Appendix E gives answers to the odd-
numbered exercises in the text. Those odd-numbered exercises with very long solutions will not
be in the text, but will be provided to students online at www.cengagebrain.com.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Figure 1 shows a chapter dependency diagram for this book. Solid arrows indicate that the
chapter at the beginning of the arrow is required before studying the chapter at the end of the
arrow. A dotted arrow indicates that the chapter at the beginning of the arrow is not essential
to studying the chapter at the end of the dotted arrow.
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6 Chapter 7
Chapter 8 Chapter 9
Chapter 10 Chapter 14
Chapter 11
Chapter 12
Chapter 13
A dotted arrow means that the chapter is not essential to studying the following chapter.
All source code and solutions have been written, compiled, and quality assurance tested
with Java 6.0 and the version of Java 7.0 available at the time this book was being typeset.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Four-color
interior design
shows
accurate code
and related
comments.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
The debugging
sections show
how to find
and correct
syntax and
semantic
(logical)
errors.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
More than
250 visual
diagrams,
both
extensive and
exhaustive,
illustrate difficult
concepts.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Numbered Examples
illustrate the key
concepts with their
relevant code. The
programming code in
these examples is
followed by a Sample
Run. An explanation
then follows that
describes what each
line in the code does.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Notes highlight
important facts
about the concepts
introduced in the
chapter.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Programming
Examples are
complete programs
featured in each
chapter. These
examples include the
accurate, concrete
stages of Input,
Output, Problem
Analysis and Algorithm
Design, and a
Complete Program
Listing.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Exercises further
reinforce learning
and ensure that
students have, in
fact, mastered the
material.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Programming
Exercises challenge
students to write
Java programs with
a specified
outcome.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
S UPPLEMENTAL
R ESOURCES
The following supplemental materials are available when this book is used in a classroom setting.
Most instructor teaching tools, outlined below, are available with this book on a single
CD-ROM, and are also available for instructor access at login.cengage.com.
ExamView!
This textbook is accompanied by ExamView, a powerful testing software package that allows
instructors to create and administer printed, computer (LAN-based), and Internet exams.
ExamView includes hundreds of questions that correspond to the topics covered in this text,
enabling students to generate detailed study guides that include page references for further
review. These computer-based and Internet testing components allow students to take exams
at their computers, and save the instructor time because each exam is graded automatically.
PowerPoint Presentations
Microsoft PowerPoint slides are available for each chapter. These slides are provided as a teaching
aid for classroom presentations, either to make available to students on the network for chapter
review, or to be printed for classroom distribution. Instructors can add their own slides for
additional topics that they introduce to the class.
Distance Learning
Course Technology is proud to present online courses in WebCT and Blackboard to provide
the most complete and dynamic learning experience possible. For more information on how
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
xxxiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition
to bring distance learning to your course, contact your local Course Technology sales
representative.
Source Code
The source code is available for students at www.cengagebrain.com. At the cengagebrain.com home
page, search for the ISBN of your title (from the back cover of your book) using the search
box at the top of the page. This will take you to the product page where these resources can
be found. The source code is also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programs are also included with the source code.
Solution Files
The solution files for all programming exercises are available for instructor download at
http://login.cengage.com and are also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programming exercises are also included with the
solution files.
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
A CKNOWLEDGMENTS
There are many people I must thank who, in one way or another, contributed to the success
of this book. First, I would like to thank those who e-mailed numerous comments that helped
to improve on the fourth edition. I am thankful to Professors S.C. Cheng and Randall Crist
for constantly supporting this project.
I owe a great deal to the following reviewers, who patiently read each page of every chapter
of the current version and made critical comments that helped to improve the book:
Nadimpalli Mahadev, Fitchburg State College and Baoqiang Yan, Missouri Western State
University. Additionally, I would like to thank Brian Candido, Springfield Technical Com-
munity College, for his review of the proposal package. The reviewers will recognize that
their suggestions have not been overlooked and, in fact, made this a better book.
Next, I express thanks to Brandi Shailer, Acquisitions Editor, for recognizing the importance
and uniqueness of this project. All this would not have been possible without the careful
planning of Senior Product Manager Alyssa Pratt. I extend my sincere thanks to Alyssa, as well
as to Content Project Manager, Lisa Weidenfeld. I also thank Sreejith Govindan of Integra
Software Services for assisting us in keeping the project on schedule. I would like to thank
Chris Scriver and Serge Palladino of the MQA department of Course Technology for patiently
and carefully proofreading the text, testing the code, and discovering typos and errors.
I am thankful to my parents for their blessings.
Finally, I am thankful to the support of my wife Sadhana, and especially my daughter Shelly,
to whom this book is dedicated. They cheered me up whenever I was overwhelmed during
the writing of this book.
We welcome any comments concerning the text. Comments may be forwarded to the
following e-mail address: malik@creighton.edu.
D.S. Malik
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
APPENDIX A
J AVA R ESERVED
W ORDS
The reserved words const and goto are not currently in use.
939
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
APPENDIX B
O PERATOR
P RECEDENCE
The following table shows the precedence of operators in Java from highest to lowest,
and their associativity.
941
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Licensed to: iChapters User
APPENDIX C
C HARACTER S ETS
This appendix lists and describes the character sets for ASCII (American Standard Code
for Information Interchange), which also comprises the first 128 characters of the Uni-
code character set, and EBCDIC (Extended Binary Coded Decimal Interchange Code).
ASCII
0 1 2 3 4 5 6 7 8 9
0 nul soh stx etx eot enq ack bel bs ht
1 lf vt ff cr so si dle dc1 dc2 dc3
2 dc4 nak syn etb can em sub esc fs gs
3 rs us b ! " # $ % & '
4 ( ) * + , - . / 0 1
5 2 3 4 5 6 7 8 9 : ;
6 < ¼ > ? @ A B C D E
7 F G H I J K L M N O
8 P Q R S T U V W X Y
9 Z [ \ ] ^ _ ` a b c
10 d e f g h i j k l m
11 n o p q r s t u v w
12 x y z { | } " del
945
Copyright 2011 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Discovering Diverse Content Through
Random Scribd Documents
true of the area which contains a number of such tumors, i. e., the
so-called pile-bearing area. Hence, surgeons of the largest
experience have practically discarded the more bungling methods
and have applied to these conditions the same radical measures
which they recommend elsewhere.
One important feature which should always be practised is
thorough dilatation of the sphincter, not only for reasons above
described, but because of the facility with which the surgeon then
exposes the diseased tissues. Any distinct tumor or series of them
may, for instance, be seized, isolated, and dissected out, either by
an elliptical incision of the mucosa or by a more blunt dissection with
scissors. The base, or pedicle, if sufficiently large to justify it, may be
ligated before the incision is completed, after which catgut sutures
may be used to close the opening in the mucosa. When the tumor is
small the suture may be made to include the bleeding points so that
even a ligature is not required. A more radical method of extending
this same principle to the entire pile-bearing area, especially when
prolapsed, or to so much of it as is affected, is the so-called
Whitehead’s operation of excision, which practically consists in
trimming off a ring of exposed mucosa, with its clusters of enlarged
and more or less pendulous veins. This ring extends from the
mucocutaneous border, at the verge of the anus, to a point perhaps
1¹⁄₂ inches above, the intent being to separate the mucosa and the
tumors from the fibers of the sphincter, which can be practically
effected in such a way that sphincter control is not lost. Hemorrhage
will be free for a few moments, but is always within control. Larger
vessels which spurt may be twisted or tied, while oozing surfaces are
included within the row of catgut sutures, which is later placed in
such a way as to unite the divided mucous tube with the skin border
at the anus. The operation is, in effect, an annular excision of the
lining of the rectum, and as such proves satisfactory. There is about
it this temporary disadvantage that the pile-bearing area thus
removed is also the sensitive area, and that for a few weeks, at least
until nerve communications have been reëstablished, there is a lack
of peculiar or normal sensibility about the parts which is annoying,
and may perhaps lead to some incontinence, but this soon passes
away. The measure is the most satisfactory of all for well-marked
cases of hemorrhoids associated with more or less ulceration and
prolapse.
An occasional dilatation, scattered here and there around the
lower end of the rectum, perhaps with a mild degree of ulceration, is
usually very satisfactorily treated by a method which it must be
confessed would be rarely used on the exterior of the body, and yet
which proves quite serviceable here, namely, the actual cautery. The
consequences of its application are obliteration of the vein, cicatricial
contraction of the overstretched tissues and eventual relief.
Other methods of operation include the use of the clamp and
cautery for removal of considerable masses, a method ordinarily less
satisfactory than excision, and the use of the ligature, with or
without incision of the mucosa at the base of the tumor, it being
thus cauterized and expected to separate by sloughing, an uncertain
procedure. None of these methods, nor others not worth
mentioning, compare with the newer methods of excision.
Much has been recently written concerning the advantage of local
anesthesia in doing these operations. This seems to have been
advocated largely for effect, although external tumors can be treated
by cocaine applications or by the ordinary injections of cocaine or
one of its substitutes. It is claimed that the infiltration of the
surrounding tissues with normal salt solution affords an effective
local anesthetic. Mere local anesthesia is not sufficient for thorough
work upon parts not easily visible, and the actual stretching of the
sphincter is half the battle in dealing with these conditions. This
cannot be thoroughly accomplished without general anesthesia.
Consequently for any well-marked hemorrhoidal condition
chloroform offers decidedly the preferable method, not alone from
considerations of comfort, but from the standpoint of permitting
more thorough and effective work to be done.
After these operations it is advisable to place within the grasp of
the anus a stiff rubber tube wrapped with gauze. It permits the
escape of flatus without distress to the patient, and it effects a
better coaptation of surfaces recently united by suture than would
otherwise be secured. Such a tube Fig. 593
may be left in situ for from six to
thirty-six hours.
Fig. 595
Fig. 601
Fig. 606