PDF C Programming From Problem Analysis To Program Design 5th Edition Barbara Doyle Download
PDF C Programming From Problem Analysis To Program Design 5th Edition Barbara Doyle Download
com
https://ebookname.com/product/c-programming-from-problem-
analysis-to-program-design-5th-edition-barbara-doyle/
OR CLICK BUTTON
DOWLOAD NOW
https://ebookname.com/product/c-programming-from-problem-
analysis-to-program-design-2nd-edition-barbara-doyle/
https://ebookname.com/product/c-programming-from-problem-
analysis-to-program-design-6th-edition-d-s-malik/
https://ebookname.com/product/c-programming-program-design-
including-data-structures-fourth-edition-d-s-malik/
https://ebookname.com/product/programming-problem-solving-
abstraction-with-c-moffat/
C How to Program Introducing Web Programming with CGI
and Object Oriented Design with the UML 4th Edition
Harvey Deitel
https://ebookname.com/product/c-how-to-program-introducing-web-
programming-with-cgi-and-object-oriented-design-with-the-uml-4th-
edition-harvey-deitel/
https://ebookname.com/product/systematic-program-design-from-
clarity-to-efficiency-1st-edition-yanhong-annie-liu/
https://ebookname.com/product/programming-c-sharp-3-0-5th-
edition-jesse-liberty/
https://ebookname.com/product/c-how-to-program-seventh-edition-
edition-deitel/
https://ebookname.com/product/c-how-to-program-8th-edition-paul-
deitel/
C# PROGRAMMING:
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN
FIFTH EDITION
Copyright 2016 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.
Copyright 2016 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.
C# PROGRAMMING:
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN
FIFTH EDITION
BARBARA DOYLE
"VTUSBMJBt#SB[JMt+BQBOt,PSFBt.FYJDPt4JOHBQPSFt4QBJOt6OJUFE,JOHEPNt6OJUFE4UBUFT
Copyright 2016 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.
This is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may be suppressed. Editorial
review has deemed that any suppressed content does not materially affect the overall learning experience. The publisher reserves the right to
remove content from this title at any time if subsequent rights restrictions require it. For valuable information on pricing, previous
editions, changes to current editions, and alternate formats, please visit www.cengage.com/highered to search by
ISBN#, author, title, or keyword for materials in your areas of interest.
Important Notice: Media content referenced within the product description or the product text may not be available in the eBook version.
Copyright 2016 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.
C# Programming: From Problem Analysis to © 2016, 2014 Cengage Learning
Program Design, Fifth Edition WCN: 02-200-203
Barbara Doyle
ALL RIGHTS RESERVED. No part of this work covered by the
copyright herein may be reproduced, transmitted, stored, or used
Product Director: Kathleen McMahon
in any form or by any means graphic, electronic, or mechanical,
Product Team Manager: Kristin McNary including but not limited to photocopying, recording, scanning,
Senior Product Manager: Jim Gish digitizing, taping, Web distribution, information networks, or
information storage and retrieval systems, except as permitted
Senior Content Developer: Alyssa Pratt
under Section 107 or 108 of the 1976 United States Copyright Act,
Product Assistant: Abigail Pufpaff without the prior written permission of the publisher.
Marketing Manager: Eric LaScola Microsoft ® is a registered trademark of the Microsoft
Senior Production Director: Wendy Troeger Corporation.
Production Director: Patty Stephan Unless otherwise noted all screenshots are courtesy of Microsoft
Corporation
Senior Content Project Manager: Jennifer
K. Feltri-George Unless otherwise noted all tables/figures exhibits are
© Cengage Learning®
Managing Art Director: Jack Pendleton
Cover image: © zeljkodan/Shutterstock.com
Production Service: SPi Global For product information and technology assistance, contact us at
Cengage Learning Customer & Sales Support, 1-800-354-9706
Compositor: SPi Global
For permission to use material from this text or product,
submit all requests online at www.cengage.com/permissions.
Further permissions questions can be e-mailed to
permissionrequest@cengage.com
Cengage Learning
20 Channel Center Street
Boston, MA 02210
USA
Copyright 2016 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.
BRIEF CONTENTS
© zeljkodan/Shutterstock.com
PREFACE xxiii
7. Arrays 399
Copyright 2016 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.
vi | C# Programming: From Problem Analysis to Program Design, Fifth Edition
GLOSSARY 1129
INDEX 1143
Copyright 2016 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.
TABLE OF CONTENTS
© zeljkodan/Shutterstock.com
Preface xxiii
INTRODUCTION TO COMPUTING
1 AND APPLICATION DEVELOPMENT 1
History of Computers 2
System and Application Software 4
System Software 5
Application Software 7
Software Development Process 7
Steps in the Program Development Process 8
Programming Methodologies 15
Structured Procedural Programming 15
Object-Oriented Programming 18
Evolution of C# and .NET 21
Programming Languages 21
.NET 23
Why C#? 25
Types of Applications Developed with C# 26
Web Applications 27
Windows Applications 28
Console Applications 28
Exploring the First C# Program 29
Elements of a C# Program 30
Comments 30
Inline Comments 31
Multiline Comments 31
Copyright 2016 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.
viii | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Copyright 2016 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.
Table of Contents | ix
Copyright 2016 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.
x | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Copyright 2016 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.
Table of Contents | xi
Copyright 2016 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.
xii | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Copyright 2016 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.
Table of Contents | xiii
Resources 386
Quick Review 386
Exercises 388
Programming Exercises 394
ARRAYS 399
7 Array Basics 400
Array Declaration 401
Array Initializers 404
Array Access 406
Sentinel-Controlled Access 411
Using Foreach with Arrays 412
Array Class 413
Arrays as Method Parameters 419
Pass by Reference 420
Array Assignment 423
Params Parameters 425
Arrays in Classes 426
Array of User-Defined Objects 428
Arrays as Return Types 429
Coding Standards 447
Guidelines for Naming Arrays 447
Advanced Array Suggestions 447
Resources 447
Quick Review 447
Exercises 448
Programming Exercises 455
Copyright 2016 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.
xiv | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Copyright 2016 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.
Table of Contents | xv
Copyright 2016 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.
xvi | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Copyright 2016 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.
Table of Contents | xvii
Copyright 2016 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.
xviii | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Copyright 2016 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.
Table of Contents | xix
Copyright 2016 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.
xx | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Copyright 2016 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.
Table of Contents | xxi
GLOSSARY 1129
INDEX 1143
Copyright 2016 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.
Copyright 2016 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.
P R E FA C E
© zeljkodan/Shutterstock.com
Why C#?
C# has gained tremendous popularity in the industry. C# is a true object-oriented lan-
guage that includes a rich set of instruction statements. C# was the language used for
development of much of .NET, the Microsoft programming paradigm that includes a
collection of more than 2,000 predefined classes that make up the Framework Class
Library (FCL). Thus, C# has access to a large collection of predefined classes similar
to those available to Java. C# provides tools that make it easy to create graphical user
interfaces—similar to the tools Visual Basic programmers have employed for years.
C# also provides the pure data crunching horsepower to which C/C++ programmers
have become accustomed. However, unlike other languages, C# was designed from
scratch to accommodate Internet and Windows applications. C# is an elegant and
simple object-oriented language that allows programmers to build a breadth of appli-
cations. C# is also a great language for mobile application development. It can run on
not only Windows platforms but is very portable and can run on Android and iOS
devices. For these reasons, C# was chosen as the language for this book.
Copyright 2016 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.
xxiv | C# Programming: From Problem Analysis to Program Design, Fifth Edition
immediately in the first chapter. It includes lots of examples and figures illustrating
basic concepts. A heavy emphasis on illustrating the visual tools that can be used
to create applications is included in this edition. However, this book goes beyond
what is traditionally found in most CS1 textbooks and, because of the inclusion of a
number of advanced applications, this textbook could also be used in an intermediate
course for students who have already been exposed to some programming concepts.
Advanced Topics
After building a solid programming foundation, this book presents rapid application
development techniques that can be used to build a number of advanced types of
applications including Windows, data-driven applications using a database, and Web
and mobile applications for smart devices. Generics, delegates, ArrayLists, dynamic
data types, abstract classes, interfaces, and many advanced object-oriented concepts
are introduced. Readers retrieve data from files and store data both to sequential and
binary files. Solutions involving multidimensional arrays and other advanced collection
classes are demonstrated. Illustrating the drag-and-drop construction approach used
with Visual Studio, Windows, and Web applications are created. Readers are introduced
to the event-driven programming model, which is based on interactively capturing and
responding to user input on Windows and Web forms. Class libraries, Windows Forms
applications, and Windows Presentation Foundation client applications are created.
Two full chapters are devoted to programming based on events and then those topics
are integrated throughout the remainder of the book. Readers are introduced to ASP.
NET for Web applications and ADO.NET for working with databases.
For first-time programmers, this book is unusual in introducing applications that
retrieve and update data in databases such as those created using Microsoft Access.
A number of visual development tools are illustrated to connect to data sources.
Other interesting topics include retrieving data using Language-Integrated Query
(LINQ), developing stand-alone .dll components (class libraries), and an introduction
to Xamarin for programming applications for mobile devices. All of these advanced
features are discussed after the reader has gained a thorough understanding of the
basic components found in programming languages.
Copyright 2016 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.
Preface | xxv
using Visual Studio 2015. All screenshots are updated to the Visual Studio 2015 IDE.
The following summarizes some of the changes in the fifth edition.
Approach
A problem-solving methodology based on object-oriented software development is
introduced early and used throughout the book. Programming Examples are pre-
sented at the end of each chapter, and each example follows a consistent approach:
analyzing the problem specifications, designing a solution, implementing the design,
and verifying or validating the solution structures.
The author believes that the best way to learn to program is to experience program-
ming. This assumption drives the material presented in this textbook. As new con-
cepts are introduced, they are described using figures and illustrations. Examples are
shown and discussed as they relate to the concept being presented. With a hands-on
approach to learning, readers practice and solidify the concepts presented by complet-
ing the end of the chapter exercises. Readers are also encouraged throughout the book
to explore and make use of the more than 2,000 classes that make up the FCL.
Copyright 2016 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.
xxvi | C# Programming: From Problem Analysis to Program Design, Fifth Edition
Every chapter begins with a list of objectives and a short overview of the previous chap-
ter. Text in each chapter is supplemented with figures and tables to help visual learners
grasp the concepts being presented. Each chapter is sprinkled with useful tips and hints
as NOTES on the concepts being presented. Code snippets and numbered examples
are embedded as new concepts are introduced in each chapter. In addition, each chap-
ter contains complete working programs illustrating an application using C#. Every
chapter ends with a Coding Standards section, which provides a summary of acceptable
conventions or guidelines pertaining to the chapter’s topics that focus on style issues.
A list of websites for readers to explore is included in a special Resources section at the
end of each chapter. A summary of the major points covered in that chapter and review
exercises in both objective and subjective formats are included. Every chapter ends with
programming exercises that give readers an opportunity to experience programming.
arithmetic procedures on the data, how to display formatted data, and how expres-
sions are evaluated using operator precedence. Chapter 3 extends the manipulation
of the data through introducing methods and behaviors of the data. Readers learn to
write statements that call methods and to write their own class methods. They learn
how to pass arguments to methods that return values and to those that do not.
Readers learn to create their own classes in Chapter 4. This chapter introduces the
components of a class including the data, property, and method members. Special
methods, including constructors, are written.
Chapter 5 introduces control structures that alter the sequential flow of execution.
Selection control constructs are introduced in Chapter 5. One-way, multiway, switch,
and ternary operators used to make decisions are illustrated. Looping is introduced
in Chapter 6. The rich set of iteration operators including while, for, do while, and
foreach are explored. Recursive solutions are also explored.
Chapter 7 discusses arrays. This chapter describes how to declare and perform com-
pile-time initialization of array elements. The Array class and its many members are
introduced. Methods of the string and ArrayList classes are included in Chapter 8.
Multidimensional arrays and other collection classes, including stacks, queues, and
hash tables, are also introduced in Chapter 8.
Chapter 9 presents a different way of programming, which is based on interactively
responding to events. A number of classes in the FCL that are used to create Windows
applications are introduced. Elements of good design are discussed in Chapter 9.
Delegates are also explored in Chapter 9. Visual Studio’s drag-and-drop approach
to rapid application development is introduced and used in these chapters. The
Windows Presentation Foundation (WPF) is also introduced in Chapter 10 as an
alternative approach to Windows Forms for creating Windows applications.
Advanced object-oriented programming features are the focus of Chapter 11. Readers
are introduced to component-based development and learn how to create their own
class library files. Inheritance, interfaces, abstract classes, sealed classes, generic types,
partial classes, and polymorphic programming are discussed in detail. Advanced fea-
tures such as overriding, overloading, and the use of virtual methods are also included
in Chapter 11. Static versus dynamic typing is also investigated in Chapter 11.
Chapter 12 discusses debugging and exception handling techniques. The chapter
introduces one of the tools available in Visual Studio, the Debugger, which can be used
to observe the run-time environment, take an up-close look at the code, and locate
logic errors. The try. . .catch. . .finally block is discussed for handling exceptions. In
addition to discussing .NET exception classes, custom exceptions are designed.
Chapter 13 presents the basics of creating, opening, closing, reading, and writing
files. The major classes used to work with file and directory systems are intro-
duced. Chapter 14 introduces a number of new namespaces collectively called ADO.
NET, which consists of a managed set of library classes that enable interaction with
Copyright 2016 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.
xxviii | C# Programming: From Problem Analysis to Program Design, Fifth Edition
databases. The chapter illustrates how ADO.NET classes are used to retrieve and
update data in databases. The visual programming tools and wizards available with
Visual Studio, which simplify accessing data, are covered in this chapter. The LINQ is
also introduced in Chapter 14.
The focus of Chapter 15 is on Web applications. Readers explore how the design
of Web-based applications differs from Windows applications. They discover the
differences between static and dynamic web pages and how HTML and Web server
controls differ. Master pages and Cascading Style Sheets are introduced. Also
included in Chapter 15 is an introduction to Xamarin used for mobile application
development. Chapter 15 illustrates how validation controls can be used to check
users’ input values and shows how the ADO.NET classes, introduced in Chapter 14,
can also be used with Web applications to access database records.
Appendix A presents suggestions for customizing the appearance and behavior of
the Integrated Development Environment (IDE). Appendix B discusses the Code
Editor features of Visual Studio. Code snippets and refactoring are described.
These new features improve programmer productivity by reducing the number of
keystrokes required to enter program statements. This appendix also illustrates
developing applications visually using class diagrams. Appendix C lists the Unicode
and ASCII (American Standard Code for Information Interchange) character sets.
Appendix D shows the precedence of the C# operators, and Appendix E lists the C#
keywords.
Features
Every chapter in this book includes the following features. These features are both con-
ducive to learning in the classroom and enable you to learn the material at your own pace.
? Syntax boxes show the general form for different types of statements.
Copyright 2016 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.
Preface | xxix
? The glossary at the end of the book lists nearly 400 key terms in alphabetical
order along with definitions for easy reference. Throughout this text, the
terms set in bold indicate that they are defined in the glossary.
From beginning to end, the concepts are introduced at a pace that is conducive to
learning. The writing style of this book is simple and straightforward, and it paral-
lels the teaching style of a classroom. The concepts introduced are described using
examples and small programs.
The chapters have two types of programs. The first type includes small programs that
are part of the numbered examples and are used to explain key concepts. This book
also features numerous case studies called Programming Examples. These Program-
ming Examples are placed at the end of the chapters to pull together many of the con-
cepts presented throughout the chapter. The programs are designed to be methodical
and workable. Each Programming Example starts with a Problem Analysis and is then
followed by the Algorithm Design. Every step of the algorithm is then coded in C#. In
addition to teaching problem-solving techniques, these detailed programs show the
user how to implement concepts in an actual C# program. Students are encouraged
to study the Programming Examples very carefully in order to learn C# effectively.
All source code and solutions have been written, compiled, and tested by quality
assurance with Visual Studio Professional 2015.
Copyright 2016 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.
F E AT U R E S OF THE BOOK
Learning
objectives appear
at the beginning
of each chapter.
Copyright 2016 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.
Numerous
visual diagrams
throughout the
text illustrate
difficult concepts.
Copyright 2016 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.
Numerous tables
are included
that describe
and summarize
information
compactly for
easy viewing.
Copyright 2016 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.
Updated screen
shots of what
readers see in
Visual Studio are
also included
throughout the
book.
Copyright 2016 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.
Non-keyword
code appears in
a different font
throughout the
text so readers can
quickly distinguish
program statements
from normal text.
Multi-color
interior design
shows accurate
C# code and
related comments.
Throughout the
book, keywords are
shown in blue and
comments appear
in green.
Numbered examples
illustrate the key
concepts with their
relevant code,
and the code is
often followed by
a sample run. An
explanation follows
that describes the
functions of the
most difficult lines
of code.
Copyright 2016 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.
Syntax boxes show
the general form
for different types
of statements.
Copyright 2016 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.
Notes provide
short quick tips
highlighting
important
concepts and
features that
might be
overlooked.
Copyright 2016 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.
Programming
Examples are
complete programs
featured at the
end of the chapter.
The examples
contain the distinct
stages of preparing
a problem
specification,
analyzing the
problem, designing
the solution,
and coding the
implementation.
Copyright 2016 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.
Coding/programming
style guidelines and
suggestions are
featured at the end
of each chapter.
Copyright 2016 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.
A special Resources
section at the end
of each chapter
offers a number of
web sites for the
reader to explore.
Copyright 2016 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.
Exercises further
reinforce learning
and ensure that
students have,
in fact, absorbed
the material.
Both objective
and subjective
types of activities
are included at
the end of each
chapter.
Copyright 2016 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.
Programming
Exercises challenge
students to write
C# programs with a
specified outcome.
Copyright 2016 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.
Special
appendices
highlight code
editor tools
and provide
suggestion for
configuring
Visual Studio
to maximum
productivity.
Copyright 2016 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.
Preface | xliii
Instructor Resources
The following teaching tools are available for download at our Instructor Companion
Site. Simply search for this text at sso.cengage.com. An instructor login is required.
Instructor’s Manual. The Instructor’s Manual that accompanies this textbook
includes additional material to assist in class preparation, including suggestions for
lecture topics.
Test Bank: Cengage Learning Testing Powered by Cognero is a flexible, online sys-
tem that allows you to:
? author, edit, and manage test bank content from multiple Cengage
Learning solutions
? deliver tests from your LMS, your classroom, or wherever you want
PowerPoint Presentations. Microsoft PowerPoint slides are available for each chap-
ter. These are offered 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 intro-
duce to the class.
Source Code for Examples. The complete Visual Studio project files for the exam-
ples included within each chapter are available for instructors and are also posted
for students on CengageBrain.com. Individual source code files are stored with a .cs
extension inside the project subdirectory.
Programming Exercises Solution Files. The complete Visual Studio project files
for the solutions to all programming exercises included at the end of the chapters are
provided. The individual source code files are stored with a .cs extension inside the
project subdirectory.
Acknowledgments
I would like to express my gratitude for the opportunity to complete the fifth edi-
tion of this book. Like the other editions, it was a huge undertaking for me. Special
thanks go out to Alyssa Pratt, Senior Content Developer, at Cengage Learning, for her
positive comments, guidance, and support. She was a pleasure to work with again on
this new edition. I am grateful to the Quality Assurance team members who verified
that each of the examples and exercise solutions worked properly. Also thanks to the
Content Manager and Copyeditor, Jennifer Feltri-George and Andrea Schein, who
provided great suggestions as we progressed with the project.
Copyright 2016 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.
xliv | C# Programming: From Problem Analysis to Program Design, Fifth Edition
I am very grateful to the following reviewers for their uplifting comments and sugges-
tions for improvements:
Wai Mok: The University of Alabama in Huntsville
Iftikhar Sikder: Cleveland State University
Leslie Spivey: Edison Community College
I hope that the reviewers will see that many of their suggestions were implemented.
The textbook is much improved because of their contributions.
Copyright 2016 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.
© zeljkodan/Shutterstock.com
CHAPTER
1
INTRODUCTION TO COMPUTING
AND APPLICATION DEVELOPMENT
I N THI S C H A P T E R , Y OU W IL L :
? Distinguish between the different types of applications that can be created with C#
Copyright 2016 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.
2 | Chapter 1: Introduction to Computing and Application Development
Computers have become such an integral part of our lives today that many of their
functions are taken for granted. Yet, only a few years ago, mobile apps, text messag-
ing, and cloud computing were unknown. Social media is one of the most power-
ful sources for news updates through platforms such as Twitter and Facebook. With
today’s smartphones, many people have the computing power of mini super comput-
ers in their pockets. Video-sharing websites such as YouTube can now be accessed with
most smartphones. Advances in computing are occurring every day. Expectations
are that tablet sales will grow by 200 percent through 2016. Over 100 million units
were sold in last year. For most consumers, tablets are not replacements for their
conventional computers but are added devices they will purchase.
Much personal computing can now occur on smaller devices. Mobile applications, or
apps, for smartphones, tablets, and other wireless devices are increasingly in demand.
Today because of smartphone apps, you don’t have to worry about being lost, being
bored, or alone. To reach this level of complexity, software development has gone
through a number of eras, and today technical advances accumulate faster and faster.
What new types of computer software will be integral to our daily lives in the future?
What types of apps will be on the wearable technology such as wristwatches or
glasses for you in the future. The focus of this book is to introduce you to application
development. Before beginning the journey into software development, a historical
perspective on computing is included to help you see the potential for advancements
that awaits you.
History of Computers
Computing dates back some 5000 years. Many consider the abacus to be the first
computer. Used by merchants of the past and present for trading transactions, the
abacus is a simple calculating device that uses a system of sliding beads on a rack for
addition and subtraction.
In 1642, another calculating device, called the Pascaline, was created. The Pascaline
had eight movable dials on wheels that could calculate sums up to eight figures long.
Both the abacus and Pascaline could perform only addition and subtraction. It was
not until the 1830s that the first general-purpose computer, the Analytical Engine,
was available.
Charles Babbage and his assistant, Lady Augusta Ada Byron, Countess of Lovelace,
designed the Analytical Engine. Although it was very primitive by today’s standards, it
was the prototype for what is known today as a general-purpose computer. The Ana-
lytical Engine included input devices, memory storage, a control unit that allowed
processing instructions in any sequence, and output devices.
Copyright 2016 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.
History of Computers | 3
In the 1980s, the U.S. Defense Department named the Ada programming language in honor 1
of Lady Lovelace. She has been called the world’s first programmer. Controversy surrounds
her title. Lady Byron was probably the fourth or fifth person to write programs. She did
programming as a student of Charles Babbage and reworked some of his calculations.
Babbage is considered the father of the computer since he conceptualized and invented
the first mechanical computer in the nineteenth century.
Many computer historians believe the present day to be in the fifth generation of
modern computing. Each era is characterized by an important advancement in com-
puter technology. In the mid-1940s, World War II, with its need for strategic types
of calculations, spurred on the first generation of general-purpose machines. These
large, first-generation computers were distinguished by the use of vacuum tubes.
They were difficult to program and limited in functionality. The operating instruc-
tions were made to order for each specific task.
The invention of the transistor in 1956 led to second-generation computers, which
were smaller, faster, more reliable, and more energy efficient than their predecessors.
The third generation, 1964–1971, saw computers become smaller, as transistors were
squeezed onto small silicon discs (single chips), which were called semiconductors.
Operating systems, as they are known today, which allowed machines to run many
different programs at once, were also first seen in third-generation systems.
As time passed, chips kept getting smaller and capable of storing more transistors,
making computers more powerful and less expensive. The Intel 4004 chip, developed
in 1971, placed the most important components of a computer (central processing
unit, memory, and input and output controls) on a minuscule chip about half the size
of a dime. Many household items such as microwave ovens, television sets, and auto-
mobiles benefited from the fourth generation of computing.
During the fourth generation, computer manufacturers tried to bring computing to
general consumers. In 1981, IBM introduced its personal computer (PC). The 1980s
saw an expansion in computer use as clones of the IBM PC made the PC even more
affordable. We also saw the development of graphical user interfaces (GUIs) and the
mouse as a handheld input device. The number of PCs in use more than doubled from
two million in 1981 to 5.5 million in 1982. Ten years later, 65 million PCs were in use.
According to the 2013 U.S. Census Bureau’s Current Population Survey, over 83.8% of
households in the United States had computers at home. Over 73% reported having a
high-speed Internet connection at home.
Copyright 2016 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.
4 | Chapter 1: Introduction to Computing and Application Development
Copyright 2016 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.
Another random document with
no related content on Scribd:
— Tanssitaan, reputetaan… antaa heinien kuivaa.
*****
*****
— Heh, olithan tuota nyt kerran sinäkin työssä, sanoi Tiina Lovisa
hyvillään.
KYMMENES LUKU.
Eikä tahtonutkaan.
*****
*****
Huomaa ja huudahtaa:
— Minä tulen!
— Miten vain.
*****
Puhuu linnustamisestaan:
— Vai ei, sinä hölmö, kun akka, Pyllykkä, todistaa, että olen
ostanut. Jos vaan nokkasi avaat, niin minä varmasti nujerran niskasi.
Jätän koko viran — elän minä muutenkin — ja sitten katkasen vaikka
kaulasi.
— Helvetti… on siinä…
Tuomari:
— Niin.
Niin, se vetää häntä, se siellä ja tämä täällä. Jos hän väsyy siellä
ja kyllästyy niinkuin jo kerran ennen, palaa varmasti tänne,
terveeseen maaperään, Kyllin luokse, joka häntä varmasti odottaa,
vaikk'ei sitä sano.
Ei, totisesti hän ei voi nyt lähteä, jollei koeta vapautua tytön ja
tämän yön lumoista.
Bertil jää.
— Ihanko varmasti?
Aatamikin nikottelee:
— Saunaan siitä!
— Elä perkuloita!
*****
Hörödii on saanut taaskin nimismiehen lähtemään korpeen, ja
nytpä heillä on varma saalis saunassa, josta viinakuninkaat eivät
jaksa eivätkä arvaa lähteä pakoon.