C Programming From Problem Analysis to Program Design 2nd Edition Barbara Doyle download pdf
C Programming From Problem Analysis to Program Design 2nd Edition Barbara Doyle download pdf
com
https://ebookname.com/product/c-programming-from-problem-
analysis-to-program-design-2nd-edition-barbara-doyle/
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebookname.com/product/c-programming-from-problem-analysis-to-
program-design-5th-edition-barbara-doyle/
ebookname.com
https://ebookname.com/product/c-programming-from-problem-analysis-to-
program-design-6th-edition-d-s-malik/
ebookname.com
https://ebookname.com/product/c-programming-program-design-including-
data-structures-fourth-edition-d-s-malik/
ebookname.com
https://ebookname.com/product/neuropsychological-assessment-5th-
edition-muriel-deutsch-lezak-diane-b-howieson-erin-d-bigler-daniel-
tranel/
ebookname.com
Interpartner Dynamics in Strategic Alliances 1st Edition
T. K. Das
https://ebookname.com/product/interpartner-dynamics-in-strategic-
alliances-1st-edition-t-k-das/
ebookname.com
https://ebookname.com/product/comparative-homeland-security-global-
lessons-wiley-series-on-homeland-defense-and-security-1st-edition-
nadav-morag/
ebookname.com
https://ebookname.com/product/animals-a-visual-encyclopedia-2nd-
edition-dk/
ebookname.com
https://ebookname.com/product/principles-of-marketing-12th-edition-
philip-kotler/
ebookname.com
C# Programming:
From Problem Analysis
to Program Design,
Second Edition
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
C# Programming:
From Problem Analysis
to Program Design,
Second Edition
Barbara Doyle
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
C# Programming: From Problem Analysis to Program Design, Second Edition
by Barbara Doyle
COPYRIGHT © 2008 Course Technology, ALL RIGHTS RESERVED. No part of this Disclaimer
a division of Thomson Learning, Inc. work covered by the copyright hereon Course Technology reserves the right
Thomson Learning™ is a trademark may be reproduced or used in any to revise this publication and make
used herein under license. form or by any means—graphic, elec- changes from time to time in its con-
tronic, or mechanical, including photo- tent without notice. The programs in
Printed in the United States of America copying, recording, taping, Web this book are for instructional purposes
distribution, or information storage only. They have been tested with care
1 2 3 4 5 6 7 8 9 TC 11 10 09 08 07 and retrieval systems—without the but are not guaranteed for any partic-
written permission of the publisher. ular intent beyond educational pur-
For more information, contact Course poses. The author and the publisher do
Technology, 25 Thomson Place, Boston, For permission to use material from not offer any warranties or representa-
Massachusetts, 02210. this text or product, contact us by tions, nor do they accept any liabilities
Or find us on the World Wide Web at: Tel (800) 730-2214 with respect to the programs.
www.course.com Fax (800) 730-2215
www.thomsonrights.com 10-digit ISBN: 1-4239-0146-0
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Brief
Contents
PREFACE xix
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
vi C# Programming: From Problem Analysis to Program Design
GLOSSARY 965
INDEX 979
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Table of
Contents
PREFACE xix
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
viii C# Programming: From Problem Analysis to Program Design
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Table of Contents ix
Types 89
Classes 89
Objects 90
Predefined Data Types 91
Value Types 92
Integral Data Types 93
Floating-Point Types 95
Decimal Types 97
Boolean Variables 98
Declaring Strings 98
Making Data Constant 99
Assignment Statements 100
Basic Arithmetic Operations 103
Increment and Decrement Operations 105
Compound Operations 108
Order of Operations 110
Mixed Expressions 112
Casts 114
Formatting Output 114
Programming Example: CarpetCalculator 118
Resources 126
Quick Review 126
Exercises 127
Programming Exercises 132
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
x C# Programming: From Problem Analysis to Program Design
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Table of Contents xi
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
xii C# Programming: From Problem Analysis to Program Design
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Table of Contents xiii
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
xiv C# Programming: From Problem Analysis to Program Design
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Table of Contents xv
Exceptions 658
Raising an Exception 661
Bugs, Errors, and Exceptions 662
Exception-Handling Techniques 664
Try…Catch…Finally Blocks 665
Exception Object 668
Exception Classes 670
Derived Classes of the Base Exception Class 670
ApplicationException Class 671
SystemException Class 671
Filtering Multiple Exceptions 673
Custom Exceptions 677
Throwing an Exception 679
Input Output (IO) Exceptions 681
Programming Example: ICW WaterDepth Application 682
Quick Review 697
Exercises 698
Programming Exercises 703
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
xvi C# Programming: From Problem Analysis to Program Design
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Table of Contents xvii
ASP.NET 841
Visual Web Developer 842
IIS 842
Web Forms Page 847
Creating a Web Page 847
Controls 854
HTML Controls 855
HTML Server Controls 860
Web Forms Server Controls 864
Available Web Forms Controls 864
Web Forms Controls of the Common Form Type 866
Adding Common Form-Type Controls 869
Validation, Custom, and Composite Controls 873
Validation Controls 873
Calender Control 876
DataGrid and GridView Controls 882
AccessDataSource 888
Using Visual Tools to Connect 889
Setting the Visibility Property 893
Other Controls 895
Web Services 898
Web Services Protocols 898
Building a Web Service 900
Using or Consuming Web Services 904
Smart Device Applications (Optional) 909
The .NET Compact Framework 909
Creating a Smart Device Application 909
Quick Review 916
Exercises 918
Programming Exercises 922
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
xviii C# Programming: From Problem Analysis to Program Design
Compiling Program Statements from the Visual Studio Command Prompt 931
Executing the Application from the Command Prompt 932
Compiler Options 933
Other Platforms 933
GLOSSARY 965
INDEX 979
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Preface
C # Programming: From Problem Analysis to Program Design requires no previous introduction
to programming and only a mathematical background of high school algebra.The book
uses C# as the programming language for software development; however, the basic pro-
gramming concepts presented can be applied to a number of other languages. Instead of
focusing on the syntax of the C# language, this book uses the C# language to present gen-
eral programming concepts. It is the belief of the author that once you develop a thorough
understanding of one programming language, you can effectively apply those concepts to
other programming languages.
Why C#?
C# is a true object-oriented language that includes a rich set of instruction statements. C#
was the language used for development of much of .NET, the new 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 graphi-
cal 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. But unlike other languages, C# was designed from scratch to accom-
modate Internet and Windows applications. For these reasons, C# was chosen as the lan-
guage for this book.
Advanced Topics
After building a solid programming foundation, this book presents rapid application develop-
ment techniques that can be used to build a number of advanced types of applications.
Generics and partial classes,which are new to .NET 2.0 are introduced. 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
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
xx C# Programming: From Problem Analysis to Program Design
interactively capturing and responding to user input on Windows and Web forms. In the past,
CS1 courses and even CS2 courses did not include this model.
As a book 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 or SQL
Server. Other interesting topics include creating and using XML Web Services, program-
ming applications for mobile devices—such as personal digital assistants (PDAs), and devel-
oping stand-alone .dll components (class libraries). All of these advanced features are
discussed after you have gained a thorough understanding of the basic components found
in programming languages.
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Preface xxi
APPROACH
A problem solving methodology based on object-oriented software development is intro-
duced early and used throughout the book. Programming Examples are presented at the end
of each chapter, and each example follows a consistent approach: analyzing the problem spec-
ifications, designing a solution, implementing the design, and verifying or validating the solu-
tion structures.
The author believes that the best way to learn to program is to experience programming.
This assumption drives the material presented in this textbook. As new concepts are intro-
duced, 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, you
practice and solidify the concepts presented by completing the end of the chapter exercises.
You are also encouraged throughout the book to explore and make use of the more than
2,000 classes that make up the Framework Class Library (FCL).
Every chapter begins with a list of objectives and a short overview of the previous chapter.
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 on the con-
cepts being presented, and code snippets are embedded as new concepts are introduced in
each chapter. In addition, each chapter contains complete working programs illustrating an
application using C#. Every chapter ends with a summary of the major points covered in
that chapter and review exercises in both objective and subjective formats. Every chapter con-
tains ten programming exercises that give you an opportunity to experience programming.
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
xxii C# Programming: From Problem Analysis to Program Design
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Preface xxiii
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
xxiv C# Programming: From Problem Analysis to Program Design
FEATURES
Every chapter in this book includes the following features.These features are both conducive
to learning in the classroom and enable you to learn the material at your own pace.
■ Four-color interior design shows accurate C# code and related comments.
■ Learning objectives offer an outline of the concepts discussed in detail in the chapter.
■ Hundreds of visual diagrams throughout the text illustrate difficult concepts.
■ Syntax boxes show the general form for different types of statements.
■ 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.
■ Notes highlight important facts about the concepts introduced in the chapter.
■ Numerous tables are included which describe and summarize information compactly
for easy viewing.
■ 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 solution.
■ Quick Reviews offer a summary of the concepts covered in the chapter.
■ Exercises further reinforce learning and ensure that students have, in fact, absorbed the
material.
■ Programming Exercises challenge students to write C# programs with a specified
outcome.
■ Glossary at the end of the book lists all the key terms in alphabetical order along with
definitions, for easy reference.
Copyright 2008 Cengage Learning, Inc. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Random documents with unrelated
content Scribd suggests to you:
As the brawny seaman who had Osceola by the arm,
reminded him of the order for silence, Osceola merely
chuckled. But he continued to do so until they were far
below the waterline in the very bowels of the ship.
“Well, this isn’t so bad, I’ve had worse quarters,” Bill 224
remarked philosophically. “When the Baron took over
this ship and needed a special brig for his prisoners, he
slapped that gate into the passageway and put others in
place of the doors to these cabins. The sidewalls are of
wood. If we had some tools, it wouldn’t be such a job to
get out of here.”
“Why, don’t you see? With all the gaff we gave the
Baron, he’ll suspect we’re in cahoots with one or more
of them—and keep them down here, where they can’t
help us.”
228
Chapter XVII
CHARLIE’S NOTE
The lads heard the door of the cabin next to them slam
shut as Hans went to his well-earned rest.
“That,” laughed Bill, “is the first bit of comedy I’ve heard
since we landed aboard this blooming pirate. That
Heinie’s a sensible man. We might as well turn in, too.
Tomorrow, I suppose, they’ll take us ashore and stand
us up against a stone fence. I for one don’t want to
think any more about it than I have to.”
232
“Dear Bill—Hans is my bath stewward. He is O.K.
Have promissed Dad will make him rich for life if he
helps you and the cheif. He will cut through the
boards to your cell. Hang your blankits down over
the edge of your upper bearth so as to deden
sound. He will push through another knife so you
can do some cuting. I think the other one better
talk or sing or something so the centry can’t here
you cuting. If you get away take Hans to. His name
will be mud after this on board the Amtonia.
“Yours truley,
“Charles Evans.”
“I have cut through to the farther slit, sir. Will the Herr
Lieutenant be good enough now to place the palm of
his hand against the piece that is to come out? There
must be no cracking of the wood when we remove it.”
Less than five minutes later, he completed his job. Hans 235
took the panel they had cut from the wall and switched
off the light in his cabin.
“Very good, sir,” returned the man, and Bill climbed out
of the bunk.
“That’s it, sir. Here are four pieces of rope and a gag.
That ought to be enough to keep Otto quiet. Will the
gentlemen please take me with them,” he asked
somewhat diffidently, “when they leave the ship?”
239
Chapter XVIII
THE FLYING FISH PLAYS ITS
PART
“Okay, boy.”
“There’s rust on that barrel,” growled Bill and held out 240
his hand. “I can see it even in this light.”
“You might call that our private Navy Yard, sir. It’s the
Baron’s shore base. He keeps a crew on duty there,
while the ships are at sea. There are storehouses, a
machine shop, the men’s quarters and a store. It’s ten
miles back to the railroad. He owns all the shore
acreage hereabouts. A high wire fence shuts in the
property from all outsiders. There are one or two big
estates up and down the coast, but the nearest house is
a good three miles away.”
“There’s no road along the coast, sir. The one from the
base runs back to the little town on the railroad. It’s in
very bad condition, sir. There is no other way out.”
“Fire away.”
“My brother, August, is deck watch aboard the Flying
Fish, sir. Usually, in port, only one man is kept aboard
her. August does not like this life. Like me, he was
shanghaied into it. Once with this outfit, there is no
getting away, unless by a miracle, like tonight, sir.
August speaks no English. May I ask him to join us?”
“Yes, sir.”
“Aye, aye, sir. There’s plenty of water but the channel to 247
the harbor is a narrow one between twin heads. You’ll
have to be careful.”
“Aye, sir,” said Bill, and sent Hans forward to haul in the
sea anchor.
The first pale rays of summer dawn were brightening
sea and land when the Stamford navigated the entrance
between Twin Heads and pushed her wicked snout into
the harbor. At the same instant, Bill landed the Flying
Fish on the calm water.
“Von Hiemskirk was all set to run for it,” he said to the 248
chief.
THE END
Those who read and enjoyed this book and the one
preceding it, (Bill Bolton—Flying Midshipman) will want
to read the next of this series, Bill Bolton and The
Hidden Danger.
Transcriber’s Notes
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
1.F.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com