C Programming From Problem Analysis to Program Design 2nd Edition Barbara Doyle pdf download
C Programming From Problem Analysis to Program Design 2nd Edition Barbara Doyle pdf download
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-5th-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/advances-in-imaging-and-electron-
physics-141-1st-edition-peter-hawkes-eds/
Divided by Borders Mexican Migrants and Their Children
1st Edition Joanna Dreby
https://ebookname.com/product/divided-by-borders-mexican-
migrants-and-their-children-1st-edition-joanna-dreby/
https://ebookname.com/product/oxford-reading-tree-level-3-more-
songbirds-phonics-stop-chatting-bill-julia-donaldson/
https://ebookname.com/product/kase-on-technical-analysis-
workbook-video-course-trading-and-forecasting-1st-edition-
cynthia-kase/
https://ebookname.com/product/bench-to-bedside-microbiology-for-
clinicians-first-edition-khardori/
https://ebookname.com/product/risky-transactions-trust-kinship-
and-ethnicity-1st-edition-frank-k-salter-editor/
Elementary Number Theory and Its Applications 5th
edition Instructor s Solutions Manual Kenneth H. Rosen
https://ebookname.com/product/elementary-number-theory-and-its-
applications-5th-edition-instructor-s-solutions-manual-kenneth-h-
rosen/
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.
Exploring the Variety of Random
Documents with Different Content
V. 23. Paroles et regards, tout est charme dans vous.
Cet éloge est trop direct, et le goût délicat de madame de
Montespan eût sans doute été plus flatté d'une louange plus fine.
Tout ce que lui dit La Fontaine est assez commun; mais il y a deux
vers bien singuliers:
FABLE II.
V. 6. Ne trouvez pas mauvais.....
Je ne sais pourquoi La Fontaine parle ainsi. On sait qu'il fut marié.
Oublierait-il sa femme? Rien n'est plus vraisemblable; il vécut loin
d'elle presque toute sa vie. Au surplus, après un Apologue excellent,
voilà une fable fort médiocre, et même on peut dire que ce n'est pas
une fable. C'est une aventure fort commune qui ne méritait guère la
peine d'être rimée.
FABLE III.
V. 1. Les Lévantins, etc...
On verra à la fin pourquoi La Fontaine met le lieu de la scène dans le
Levant.
Tout le monde a retenu ces deux vers qui expriment si bien le vœu
d'une âme douce et insouciante; mais ce sentiment est encore
mieux exprimé dans le charmant morceau de la fin de cet Apologue:
Heureux qui vit chez soi, etc.
V. 28. Cherchez, dit l'autre ami, etc.
Cette amitié là n'est pas bien vive, ce n'est pas comme celle des
deux amis du Monomotapa, livre 8, fable II. Mais dans cette fable-ci,
il y a un des deux amis qui est un avare ou un ambitieux; et ces
gens-là sont aimés froidement et aiment encore moins.
V. 31. Vous reviendrez bientôt....
Celui-ci connaît le monde et a bien pris son parti.
V. 33. L'ambitieux, ou, si l'on veut, l'avare.....
Vers admirable. En effet, l'ambition dans nos états modernes n'est
guère que de l'avarice. Cela est si vrai qu'on demande sur les places
les plus honorables: combien cela vaut-il? quel en est le revenu?
V. 41. Bref, se trouvant à tout, et n'arrivant à rien...
Ce vers-là devrait être la devise de certains vieux courtisans que l'on
connaît.
V. 5. ... Des temples à Surate.
Voilà qu'il se fait marchand.
V. 78. Il ne sait que par oui-dire.
La Fontaine est toujours animé, toujours plein de mouvement et
d'abondance, lorsqu'il s'agit d'inspirer l'amour de la retraite, de la
douce incurie, de la médiocrité dans les désirs. Voyez cette
apostrophe: Et ton empire, Fortune! Et puis cette longue période qui
semble se prolonger comme les fausses espérances que la fortune
nous donne, et l'adresse avec laquelle il garde pour la fin: Sans que
l'effet aux promesses réponde. Ce sont là de ces traits qui
n'appartiennent qu'à un grand poète.
FABLE XIII.
FABLE XV.
Il est aisé de voir qu'il y a ici, dans les mots, une contradiction qui
nuit à la liaison des idées. Un torrent réveille l'idée d'une chose qui
passe, et cela fut et sera toujours, exprime précisément l'idée
contraire.
V. 10. Perdait-on un chiffon, avait-on, etc.....
Ces cinq vers sont charmans. C'est une peinture de mœurs qui est
encore fidèle de nos jours; et ce dernier trait: Pour se faire annoncer
ce que l'on desirait, développe les derniers replis du cœur humain.
Il y a un mot d'omis dans l'imprimé, il faut lire:
Chez la devineresse aussitôt on courait.
Sans quoi il n'y a point de vers. Voyez le vers 13.
Fallut deviner.
Dans ce style familier, on peut supprimer il et dire fallut au lieu de il
fallut.
Et gagner malgré soi...
C'est en partie ce qui arriva au Médecin malgré lui de Molière.
Force écoutans....
Le lecteur croit que La Fontaine va ajouter, parce que cet orateur est
l'oracle du barreau. Point du tout; il ajoute, demandez-moi pourquoi,
et se moque à la fois et du public et de l'avocat. C'est une épée à
deux tranchans. C'est l'art des grands maîtres de savoir se jouer à
propos de leur sujet.
FABLE XVI.
La Fontaine possède cet art, qui dit sans s'avilir les plus petites
choses, selon l'expression de Boileau; mais nous verrons cette idée
exprimée encore bien plus poétiquement dans la fable quinzième du
livre 10.
V. 19. .... Où lui-même il n'entrait qu'en rampant!
Elle voudrait en dégoûter Jeannot Lapin, car elle n'est pas elle-même
bien sûre de ses droits.
V. 20. Et quand ce serait un royaume.
Il est plaisant de voir l'importante question de la propriété très-bien
discutée à l'occasion d'un trou de lapin. Le dénouement de cette
fable ressemble un peu à celui de l'huitre et des plaideurs, sauf qu'il
est plus tragique pour les parties disputantes.
FABLE XVII.
V. 1. Le serpent a deux parties.
Cette fable écrite du style le plus simple, et bien moins ornée que les
précédentes, n'est pas d'une grande application dans nos mœurs;
mais elle en avait beaucoup dans nos anciennes démocraties.
Je n'aime pas ces petits vers,
V. 8. Pour le pas....
V. 11. Et lui dit:
FABLE XVIII.
La petite aventure que raconte ici La Fontaine, arriva à Londres vers
ce temps-là, et donna lieu à cette pièce de vers, qu'il plaît à La
Fontaine d'appeler une fable.
V. 14. J'en dirai quelque jour les raisons amplement.
Cela n'a l'air que d'une plaisanterie: cependant La Fontaine s'avisait
quelquefois de traiter des sujets de philosophie et de physique,
auxquels il n'entendait pas grand-chose. Il s'est donné la peine de
faire un poème en quatre chants sur le quinquina. Au reste le
Prologue de cette fable-ci serait excellent, si on faisait une coupure
après le treizième vers; que l'on passât tout de suite au trentième,
quand l'eau courbe un bâton. Tout ce que dit le poète, est exprimé
avec autant d'exactitude que pourrait en avoir un philosophe qui
écrirait en prose.
V. 47. Qui présageait sans doute un grand événement.
On croyait encore que les astres avaient de l'influence sur nos
destinées.
LIVRE HUITIÈME.
FABLE I.
Ce premier Apologue est parfait; non qu'il soit aussi brillant, aussi
riche de poésie, aussi varié, que le sont quantité d'autres. Ce n'est
que le ton d'une raison sage, simple et tranquille. On a dit que
Boileau était le premier parmi nous qui eût mis la raison en vers. Il
me semble qu'il est le premier qui ait mis en vers les préceptes de la
raison, en matière de goût et de littérature; mais La Fontaine a mis
en vers les préceptes de la raison universelle, comme Molière y a mis
ceux qui sont relatifs à la société; et ces deux empires sont plus
étendus que ceux du goût et de la littérature.
Le ton du Prologue est touchant comme il devait l'être sur un sujet
qui intéresse tous les hommes. Quel vers que celui-ci!
V. 5. Ce temps, hélas! embrasse tous les temps.
Et à la fin de la pièce, quoi de plus admirable que cet autre:
V. dernier. Le plus semblable aux morts meurt le plus à regret.
FABLE II.
V. 1. Un savetier chantait, etc....
Voici un Apologue d'un ton propre à bannir le sérieux du précédent.
C'est La Fontaine dans tout son talent, avec sa grâce, sa variété
ordinaire. La conversation du savetier et du financier ne serait pas
indigne de Molière lui-même; il dut être sur-tout frappé du trait:
Et de cet autre:
Il y a un autre trait qui dut donner à rêver à Molière, c'est celui, plus
content qu'aucun des sept Sages. Molière, si philosophe, et malgré
sa philosophie, si malheureux, dut faire quelque attention à ce vers.
Ne relevons pas quelques mauvaises rimes, comme celle de
monsieur, qu'on pardonnait alors parce qu'elle rimait aux yeux; et
cette autre, naïveté et curé.
FABLE III.
V. 5. .... Il en est de tous arts.
Je ne sais ce que cela veut dire. Veut-il dire que, dans toutes les
professions, il y a des gens qui se mêlent de médecine? en ce cas,
cela est mal exprimé. Ce n'est pas sa coutume.
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