ony Gaddis Haywood Community College STARTING OUT WITH PEARSON Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto

Similar documents
Visual C# Tony Gaddis. Haywood Community College STARTING OUT WITH. Piyali Sengupta. Third Edition. Global Edition contributions by.

Prelude to Programming

Database Concepts. David M. Kroenke UNIVERSITATSBIBLIOTHEK HANNOVER

PROBLEM SOLVING USING JAVA WITH DATA STRUCTURES. A Multimedia Approach. Mark Guzdial and Barbara Ericson PEARSON. College of Computing

World Wide Web PROGRAMMING THE PEARSON EIGHTH EDITION. University of Colorado at Colorado Springs

THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

Programming. In Ada JOHN BARNES TT ADDISON-WESLEY

Access ComprehGnsiwG. Shelley Gaskin, Carolyn McLellan, and. Nancy Graviett. with Microsoft

Essentials of Database Management

Business Driven Data Communications

Data Structures and Abstractions with Java

This page intentionally left blank

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

MariaDB Crash Course. A Addison-Wesley. Ben Forta. Upper Saddle River, NJ Boston. Indianapolis. Singapore Mexico City. Cape Town Sydney.

This page intentionally left blank

Objects First with Java

DATA AND COMPUTER COMMUNICATIONS

Systems:;-'./'--'.; r. Ramez Elmasri Department of Computer Science and Engineering The University of Texas at Arlington

Search Engines Information Retrieval in Practice

Data Structures and Abstractions with Java

CJT^jL rafting Cm ompiler

Programming in Python 3

Integrated Approach. Operating Systems COMPUTER SYSTEMS. LEAHY, Jr. Georgia Institute of Technology. Umakishore RAMACHANDRAN. William D.

Real-Time Systems and Programming Languages

FUNDAMENTALS OF. Database S wctpmc. Shamkant B. Navathe College of Computing Georgia Institute of Technology. Addison-Wesley

CRYPTOGRAPHY AND NETWORK SECURITY

PYTHON. p ykos vtawynivis. Second eciitiovl. CO Ve, WESLEY J. CHUN

HCS12 Microcontroller and Embedded Systems: Using Assembly and C with CodeWarrior 1 st Edition

FUNDAMENTALS OF SEVENTH EDITION

Framework Design Guidelines

DATA ABSTRACTION AND PROBLEM SOLVING WITH JAVA

MACHINES AND MECHANISMS

AND ASSURANCE AN INTEGRATED APPROACH SIXTEENTH EDITION GLOBAL EDITION

Networking Security Essentials 4th Edition Solution Manual

Contributor. International Edition contributions by. Piyali Sengupta PEARSON. New York San Francisco Upper

^l^s^^^^^^^^^^s^^^ ^.1^L^ gs *^gs (s^s^^^^s^^ ^S^^^^ls

The Unified Modeling Language User Guide

DB2 SQL Tuning Tips for z/os Developers

MECHATRONICS. William Bolton. Sixth Edition ELECTRONIC CONTROL SYSTEMS ENGINEERING IN MECHANICAL AND ELECTRICAL PEARSON

CLASSIC DATA STRUCTURES IN JAVA

JAVASCRIPT FOR PROGRAMMERS

Starting Out With C From Control Structures To Objects Plus Myprogramminglab With Pearson Etext Access Card Package 8th Edition

An Introduction to Search Engines and Web Navigation

MyProgram m i ng Lab. get with the programming. Through the power of practice and immediate personalized

Software Engineering Ian Sommerville Pearson Education File Type

DATABASE SYSTEM CONCEPTS

Web Development and Design Foundations with HTML5

Microsoft Visual Studio 2010

Workbook for C++ THIRD EDITION. Yedidyah Langsam, Ph.D. Brooklyn College of the City University of New York. Custom Publishing

MODERN DATABASE MANAGEMENT

Welcome to Starting Out with Programming Logic and Design, Third Edition.

SQL Queries. for. Mere Mortals. Third Edition. A Hands-On Guide to Data Manipulation in SQL. John L. Viescas Michael J. Hernandez

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

Application Programming

Virtualization from the Trenches

\ Smart Client 0" Deploymentwith v^ ClickOnce

AssEivibly LANquAqE for

Domain-Specific. Languages. Martin Fowler. AAddison-Wesley. Sydney Tokyo. With Rebecca Parsons

Fundamentals of. Database Systems. Shamkant B. Navathe. College of Computing Georgia Institute of Technology PEARSON.

Programming. Principles and Practice Using C++ Bjarne Stroustrup. / Addison-Wesley. Second Edition

Core Java Volume Ii Advanced Features 10th Edition

Cloud Computing and SOA Convergence in Your Enterprise

Quality Code. Software Testing Principles, Practices, and Patterns. Stephen Vance. AAddison-Wesley

IPHONE FOR PROGRAMMERS: AN APP-DRIVEN APPROACH

This page intentionally left blank

Digital System Design with SystemVerilog

Learning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

ECLIPSE RICH CLIENT PLATFORM

C++ Primer, Fifth Edition

Modern Information Retrieval

Harvey Deitel. Abbey Deitel

C for Electronic Engineering

The Java Tutorial. A Short Course on the Basics. Raymond Gallardo. Sowmya Kannan. AAddison-Wesley. Sharon Biocca Zakhour.

Object-Oriented Programming in C# (VS 2015)

Object-Oriented Programming in C# (VS 2012)

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Fit for Developing Software

C# 2008 and.net Programming for Electronic Engineers - Elektor - ISBN

VHDL. Douglas L. Perry. Third Edition

FrontPage 98: The Complete Reference

OpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak

DATA STRUCTURES AND PROBLEM SOLVING USING JAVA

Software Engineering Ian Sommerville 7th Edition

1. A Web Form created in Visual Basic can only be displayed in Internet Explorer. True False

LATEX. Leslie Lamport. Digital Equipment Corporation. Illustrations by Duane Bibby. v ADDISON-WESLEY

Networking. Second Edition. Jeffrey S. Beasley. New Mexico State University

Elements Of Programming Interviews In Python The Insiders Guide

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

Chapters and Appendix F are PDF documents posted online at the book s Companion Website (located at

Refactoring HTML. Improving the Design of Existing Web Applications. Elliotte Rusty Harold. TT rvaddison-wesley

egensburg, February 1st, 2005

Programming Wireless Devices with the Java 2 Platform, Micro Edition

Essentials. Oracle Solaris Cluster. Tim Read. Upper Saddle River, NJ Boston Indianapolis San Francisco. Capetown Sydney Tokyo Singapore Mexico City

Oracle Certified Associate Java Se 7 Programmer Study Guide

Course materials Reges, Stuart, and Stepp, Martin. Building Java Programs: A Back to Basics Approach. 2d ed. (Boston: Addison-Wesley, 2011).

Simulation Modeling and Analysis

Modern C++ Design. Generic Programming and Design Patterns Applied. Andrei Alexandrescu. AAddison-Wesley

Modern C++ Design. Generic Programming and Design Patterns Applied. Andrei Alexandrescu. .~Addison-Wesley

Opengl Programming On Mac Os X Architecture Performance

Modern C++ Design. Generic Programming and Design Patterns Applied. Andrei Alexandrescu

Transcription:

STARTING OUT WITH J^"* 1 Ti * ony Gaddis Haywood Community College PEARSON Boston Columbus Indianapolis New York San Francisco Upper Saddle River Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo

Preface 11 Chapter 1 Introduction to Computers and Programming 17 1.1 Introduction 17 1.2 Hardware and Software 18 1.3 How Computers Store Data 23 1.4 How a Program Works 27 1.5 Graphical User Interfaces 34 1.6 Objects 37 1.7 The Program Development Process 39 1.8 Getting Started with the Visual Studio Environment 43 TUTORIAL 1-1: Starting Visual Studio and Setting Up the Environment 44 TUTORIAL 1-2: Starting a New Visual C# Project 47 TUTORIAL 1-3: Saving and Closing a Project 49 TUTORIAL 1-4: Opening an Existing Project 58 TUTORIAL 1-5: Getting Familiar with the Visual Studio Environment 60 Key Terms 61 Review Questions 62 Programming Problems 67 Chapter 2 Introduction to Visual C# 69 2.1 Getting Started with Forms and Controls 69 2.2 Creating the GUI for Your First Visual C# Application: The Hello World Application 78 TUTORIAL 2-1: Creating the GUI for the Hello World Application 79 2.3 Introduction to C# Code 83 2.4 Writing Code for the Hello World Application 93 TUTORIAL 2-2: Writing Code for the Hello World Application 93 2.5 Label Controls 95 TUTORIAL 2-3: Creating the Language Translator Application 104 2.6 Making Sense of IntelliSense 107 2.7 PictureBox Controls 108 TUTORIAL 2-4: Creating the Flags Application 112 TUTORIAL 2-5: Creating the Card Flip Application 116 2.8 Comments, Blank Lines, and Indentation 119 2.9 Writing the Code to Close an Application's Form 122 2.10 Dealing with Syntax Errors 122 Key Terms 124 Review Questions 124 Programming Problems 129 Chapter 3 Processing Data 133 3.1 Reading Input with TextBox Controls 133 3.2 A First Look at Variables 135

Contents 7 TUTORIAL 3-1: The Birth Date String Application 142 3.3 Numeric Data Types and Variables 147 3.4 Performing Calculations 152 3.5 Inputting and Outputting Numeric Values 157 TUTORIAL 3-2: Calculating Fuel Economy 162 3.6 Formatting Numbers with the Tostring Method 165 TUTORIAL 3-3: Creating the Sale Price Calculator Application with Currency Formatting 168 3.7 Simple Exception Handling 172 TUTORIAL 3-4: Creating the Test Average Application with Exception Handling 176 3.8 Using Named Constants 180 3.9 Declaring Variables as Fields 181 TUTORIAL 3-5: Creating the Change Counter Application 185 3.10 Using the Math Class 189 3.11 More GUI Details 191 Key Terms 201 Review Questions 201 Programming Problems 206 Chapter 4 Making Decisions 211 4.1 Decision Structures and the if Statement 211 TUTORIAL 4-1: Completing the Test Score Average Application 216 4.2 The if-eise Statement 220 TUTORIAL 4-2: Completing the Payroll with Overtime Application 222 4.3 Nested Decision Structures 226 TUTORIAL 4-3: Completing the Loan Qualifier Application 228 4.4 Logical Operators 237 4.5 bool Variables and Flags 242 4.6 Comparing Strings 242 4.7 Preventing Data Conversion Exceptions with the TryParse Methods... 246 TUTORIAL 4-4: Calculating Fuel Economy 251 4.8 Input Validation 254 4.9 Radio Buttons and Check Boxes 255 TUTORIAL 4-5: Creating the Color Theme Application 260 4.10 The switch Statement 262 4.11 Introduction to List Boxes 265 TUTORIAL 4-6: Creating the Time Zone Application 267 Key Terms 271 Review Questions 271 Programming Problems 276 Chapter 5 Loops, Files, and Random Numbers 281 5.1 More About ListBoxes 281 5.2 The while Loop 283 TUTORIAL 5-1: Using a Loop to Calculate an Account Balance 287 TUTORIAL 5-2: Enhancing the Ending Balance Application 290 5.3 The++and--operators 294 5.4 The for Loop 295 TUTORIAL 5-3: Using the for Loop 300 5.5 The do-while 303

8 Contents 5.6 Using Files for Data Storage 305 TUTORIAL 5-4: Writing Data to a Text File 311 TUTORIAL 5-5: Appending Data to the Friend.txt File 316 TUTORIAL 5-6: Using a Loop to Read to the End of a File 324 TUTORIAL 5-7: Calculating a Running Total 328 5.7 The OpenFileDialog and SaveFileDialog Controls 331 5.8 Random Numbers 337 TUTORIAL 5-8: Simulating Coin Tosses 339 5.9 The Load Event 342 TUTORIAL 5-9: Creating a Load Event Handler 343 Key Terms 346 Review Questions 346 Programming Problems 349 Chapter 6 Modularizing Your Code with Methods 353 6.1 Introduction to Methods 353 6.2 void Methods 355 TUTORIAL 6-1: Creating and Calling Methods 359 6.3 Passing Arguments to Methods 363 TUTORIAL 6-2: Passing an Argument to a Method 366 6.4 Passing Arguments by Reference 374 TUTORIAL 6-3: Using an Output Parameter 377 6.5 Value-Returning Methods 381 TUTORIAL 6-4: Writing a Value-Returning Method 386 TUTORIAL 6-5: Modularizing Input Validation with a Boolean Method 389 Key Terms 395 Review Questions 395 Programming Problems 398 Chapter 7 Arrays and Lists 403 7.1 Value Types and Reference Types 403 7.2 Array Basics 406 TUTORIAL 7-1: Using an Array to Hold a List of Random Lottery Numbers 413 7.3 Working with Files and Arrays 418 7.4 Passing Arrays as Arguments to Methods 421 7.5 Some Useful Array Algorithms 428 TUTORIAL 7-2: Processing an Array 438 7.6 Advanced Algorithms for Sorting and Searching Arrays 443 7.7 Two-Dimensional Arrays 450 TUTORIAL 7-3: Completing the Seating Chart Application 453 7.8 Jagged Arrays 459 7.9 The List Collection 460 TUTORIAL 7-4: Completing the Test Score List Application 466 Key Terms 472 9 Review Questions and Exercises 472 Programming Problems 475 Chapter 8 More about Processing Data 479 8.1 Introduction 479 8.2 String and Character Processing 479 TUTORIAL 8-1: Completing the Password Validation Application 485

Contents 9 TUTORIAL 8-2: Completing the Telephone Format Application 498 TUTORIAL 8-3: Completing the Telephone Unformat Application 502 TUTORIAL 8-4: Completing the CSV Reader Application 509 8.3 Structures 514 TUTORIAL 8-5: Completing the Phonebook Application 523 8.4 Enumerated Types 529 TUTORIAL 8-6: Completing the Color Spectrum Application 532 8.5 The ImageList Control 536 TUTORIAL 8-7: Completing the Random Card Application 539 Key Terms 542 Review Questions 542 Programming Problems 546 Chapter 9 Classes and Multiform Projects 551 9.1 Introduction to Classes 551 TUTORIAL 9-1: Creating and Using the Coin Class 558 9.2 Properties 563 TUTORIAL 9-2: Creating and Using the Cellphone Class 566 9.3 Parameterized Constructors and Overloading 571 TUTORIAL 9-3: Creating and Using the BankAccount Class 572 9.4 Storing Class Type Objects in Arrays and Lists 578 TUTORIAL 9-4: Completing the Cell Plume Inventory Application 580 9.5 Finding the Classes and Their Responsibilities in a Problem 584 9.6 Creating Multiple Forms in a Project 592 TUTORIAL 9-5: Creating an Application with Two Forms 597 TUTORIAL 9-6: Accessing a Control on a Different Form 601 Key Terms 607 Review Questions 607 Programming Problems 611 Chapter 10 Inheritance and Polymorphism 615 10.1 Inheritance 615 TUTORIAL 10-1: Creating and Testing the SavingsAccount and CDAccount Classes 625 10.2 Polymorphism 633 TUTORIAL 10-2: Completing the Polymorphism Application 638 10.3 Abstract Classes 643 TUTORIAL 10-3: Completing the Computer Science Student Application 645 Key Terms 650 Review Questions 650 Programming Problems 653 Chapter 11 Databases 655 11.1 Introduction to Database Management Systems 655 11.2 Tables, Rows, and Columns 657 11.3 Creating a Database in Visual Studio 660 TUTORIAL 11-1: Starting the Phone Book Application and Creating the Phonelist.mdf Database,. 661 11.4 The DataCridView Control 668 TUTORIAL 11-2: Completing the Phone Book Application 669 11.5 Connecting to an Existing Database and Using Details View Controls 676

10 Contents TUTORIAL 11-3: Creating the Products Application and Using... a Details View 677 11.6 More About Data-Bound Controls 686 TUTORIAL 11-4: Creating the Product Lookup Application 690 TUTORIAL 11-5: Creating the Multiform Products Application 692 11.7 Selecting Data with the SQL select Statement 698 TUTORIAL 11-6: Creating the Product Queries Application 704 TUTORIAL 11-7: Creating the Product Queries Application 713 TUTORIAL 11-8: Creating the Product Search Application 718 Key Terms 723 Review Questions 723 Programming Problems 727 Appendix A C# Primitive Data Types 729 Appendix B Additional User interface Controls 731 Appendix C ASCII/Unicode Characters 751 Appendix D Answers to Checkpoint Questions 753 Index 773