100% found this document useful (3 votes)
22 views

(eBook PDF) Fundamentals of C# Programming for Information Systems 2nd Edition download

The document is a promotional and informational text for the eBook 'Fundamentals of C# Programming for Information Systems, 2nd Edition', which teaches C# programming fundamentals through practical applications and graphical interfaces. It outlines the book's structure, including key features, target audience, and new content added in this edition, such as chapters on web application development and object-oriented programming. Additionally, it provides links for downloading the book and supplementary resources for students and instructors.

Uploaded by

pakessecoyyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
22 views

(eBook PDF) Fundamentals of C# Programming for Information Systems 2nd Edition download

The document is a promotional and informational text for the eBook 'Fundamentals of C# Programming for Information Systems, 2nd Edition', which teaches C# programming fundamentals through practical applications and graphical interfaces. It outlines the book's structure, including key features, target audience, and new content added in this edition, such as chapters on web application development and object-oriented programming. Additionally, it provides links for downloading the book and supplementary resources for students and instructors.

Uploaded by

pakessecoyyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

(eBook PDF) Fundamentals of C# Programming for

Information Systems 2nd Edition download

https://ebooksecure.com/product/ebook-pdf-fundamentals-of-c-
programming-for-information-systems-2nd-edition/

Download full version ebook from https://ebooksecure.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebooksecure.com
to discover even more!

(eBook PDF) Fundamentals of C# Programming for


Information Systems 2nd Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-c-
programming-for-information-systems-2nd-edition-2/

(eBook PDF) Fundamentals of Information Systems 9th


Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-
information-systems-9th-edition/

(eBook PDF) Fundamentals of Information Systems 8th


Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-
information-systems-8th-edition/

Fundamentals of Information Systems 9th Edition Ralph


Stair - eBook PDF

https://ebooksecure.com/download/fundamentals-of-information-
systems-ebook-pdf/
Essentials of MIS (Management Information Systems),
15th Global Edition Kenneth C. Laudon - eBook PDF

https://ebooksecure.com/download/essentials-of-mis-management-
information-systems-15th-global-edition-ebook-pdf/

Essentials of MIS (Management Information Systems),


15th Global Edition Kenneth C. Laudon - eBook PDF

https://ebooksecure.com/download/essentials-of-mis-management-
information-systems-15th-global-edition-ebook-pdf-2/

(eBook PDF) Management Information Systems for the


Information 9th

http://ebooksecure.com/product/ebook-pdf-management-information-
systems-for-the-information-9th/

Fundamentals of Ecosystem Science 2nd Edition Kathleen


C. Weathers - eBook PDF

https://ebooksecure.com/download/fundamentals-of-ecosystem-
science-ebook-pdf/

(eBook PDF) Fundamentals of Communication Systems,


Global Edition 2nd Edition

http://ebooksecure.com/product/ebook-pdf-fundamentals-of-
communication-systems-global-edition-2nd-edition/
6.5 Getting User Input from Controls ................................................................................................... 183
6.6 Working with ComboBoxes............................................................................................................ 186
6.7 Working with ListBoxes ................................................................................................................. 196
6.8 Windows Presentation Foundation (WPF) ..................................................................................... 201
Exercises ............................................................................................................................................... 203
Chapter 7: Arrays ................................................................................................205
7.1 Introduction to One-Dimensional Arrays ....................................................................................... 205
Tutorial 1: Working with 1-D Arrays: Test Scores Application ........................................................... 208
7.2 Assigning a Value to an Element of an Array................................................................................. 211
7.3 Accessing Elements of an Array Using the Index .......................................................................... 212
7.4 Accessing Elements of an Array Using the foreach Loop .............................................................. 215
7.5 Copying an Array............................................................................................................................ 217
7.6 Looking Up Values in an Array ...................................................................................................... 221
Tutorial 2: Lookup Units Sold Using 1-D Arrays................................................................................. 222
Exercises ............................................................................................................................................... 224
Chapter 8: Sequential Files and Arrays.............................................................226
8.1 Introduction to Text Files................................................................................................................ 226
Tutorial 1: Reading Text Files .............................................................................................................. 229
8.2 Splitting a Row: Split Method ........................................................................................................ 231
8.3 Reading Data from Files into Arrays .............................................................................................. 234
8.4 Additional Methods of Arrays ........................................................................................................ 241
Tutorial 2: Looking Up Phone Numbers Using Arrays ........................................................................ 242
Tutorial 3: Using a ComboBox to Select the Search Name .................................................................. 246
8.5 Writing to Text Files ....................................................................................................................... 248
Tutorial 4: Writing Scores to Text File ................................................................................................. 248
8.6 SaveFileDialog Control .................................................................................................................. 255
8.7 Passing Arrays to Methods ............................................................................................................. 259
Tutorial 5: Passing Arrays to Compute Average .................................................................................. 259
8.8 Two-Dimensional (2-D) Arrays ...................................................................................................... 263
Tutorial 6: 2-D Array to Find the Sales for a Product........................................................................... 267
Exercises ............................................................................................................................................... 271
Rentals Assignment 2 ........................................................................................................................... 272
Help Desk Assignment 2 ...................................................................................................................... 274
Chapter 9: Collections .........................................................................................276
9.1 Introduction to Collections.............................................................................................................. 276
9.2 List<T> Collection .......................................................................................................................... 278
Tutorial 1: Looking Up Sales Data Using a List ................................................................................... 279
9.3 Dictionary<TKey, TValue> Collection .......................................................................................... 285
Tutorial 2: Dictionary with Product# as Key and Price as Value ......................................................... 287
Tutorial 3: Dictionary with Product# as Key and Sales Array as Value ............................................... 293
Exercises ............................................................................................................................................... 297
Chapter 10: Graphical User Interface: Additional Controls...........................298
10.1 ListView: Features ........................................................................................................................ 298
10.2 Adding Items to ListView ............................................................................................................. 299
Tutorial 1: Selecting a Show from a ListView ..................................................................................... 302
10.3 Accessing Data from a ListView .................................................................................................. 302
10.4 Forms with Tab Pages ................................................................................................................... 308
Tutorial 2: Multipage Form with TabControl ....................................................................................... 308
Exercises ............................................................................................................................................... 310
Chapter 11: Multi-form Applications and Menus ............................................312
11.1 Introduction ................................................................................................................................... 312
11.2 Accessing an Existing Form from Another................................................................................... 313
Tutorial 1: Multi-form Financial Planning Application ........................................................................ 315
11.3 Sharing a Method between Multiple Forms .................................................................................. 318
Tutorial 2: Sharing the LoadDictionary Method between Forms ......................................................... 319
11.4 Closing a Parent Form .................................................................................................................. 325
11.5 Menus............................................................................................................................................ 328
11.6 ToolStrips...................................................................................................................................... 332
Exercises ............................................................................................................................................... 334
Chapter 12: Databases .........................................................................................335
12.1 Introduction ................................................................................................................................... 336
12.2 Creating Database Objects ............................................................................................................ 336
Tutorial 1: Display Employee Records Using the Wizard .................................................................... 337
12.3 Displaying Data in a DataGridView ............................................................................................. 340
12.4 Accessing Data Items from a DataGridView ................................................................................ 346
12.5 Displaying Data in Details View .................................................................................................. 349
12.6 Finding the Record for a Selected Key ......................................................................................... 351
Tutorial 2: Find Employee Records Using the Wizard ......................................................................... 352
12.7 Selecting a Group of Records Using the Binding Source ............................................................. 356
12.8 Selecting Records Using the Table Adapter ................................................................................. 362
Tutorial 3: Parameter Query to Select Records..................................................................................... 363
12.9 Untyped Datasets: Displaying Records......................................................................................... 365
Tutorial 4: Display Records Using Untyped Datasets .......................................................................... 366
12.10 Untyped Datasets: Selecting Records ......................................................................................... 375
Tutorial 5: Select Records Using Untyped Datasets ............................................................................. 377
12.11 Untyped Datasets: Add/Edit/Delete Records .............................................................................. 384
Tutorial 6: Add/Edit/Delete Using Untyped Datasets........................................................................... 385
12.12 Command Object and DataReader .............................................................................................. 394
Tutorial 7: SqlCommand and SqlDataReader to Work with Tables ..................................................... 396
Exercises ............................................................................................................................................... 405
Rentals Assignment 3 ........................................................................................................................... 407
Help Desk Assignment 3 ...................................................................................................................... 407
Chapter 13: Object-Oriented Programming .....................................................414
13.1 Introduction to Objects and Classes .............................................................................................. 415
13.2 Classes versus Objects .................................................................................................................. 415
13.3 Information Hiding (Encapsulation) ............................................................................................. 417
Tutorial 1: Create an Employee Class................................................................................................... 419
13.4 Properties ...................................................................................................................................... 423
Tutorial 2: User Interface and Properties .............................................................................................. 426
13.5 Calling Methods (Sending Messages to Objects) ......................................................................... 434
Tutorial 3: Calling Methods and Passing Data between Forms ............................................................ 435
Exercises ............................................................................................................................................... 448
Chapter 14: Inheritance ......................................................................................450
14.1 Introduction to Inheritance ............................................................................................................ 451
14.2 Implementing Inheritance ............................................................................................................. 452
Tutorial 1: Creating Subclasses ............................................................................................................ 454
14.3 Using Subclasses and Super Classes............................................................................................. 458
14.4 Overriding Methods ...................................................................................................................... 459
Tutorial 2: Implementing the GrossPay Method................................................................................... 462
14.5 Polymorphism ............................................................................................................................... 467
Tutorial 3: Dynamic Dispatch and the ToString Method...................................................................... 468
14.6 Abstract Classes and Interfaces..................................................................................................... 472
Tutorial 4: Interfaces ............................................................................................................................. 473
14.7 Using Interfaces to Sort Collections ............................................................................................. 480
Tutorial 5: Sorting Employees .............................................................................................................. 483
14.8 Access Modifiers in C# ................................................................................................................. 486
Exercises ............................................................................................................................................... 488
Chapter 15: Introduction to Web Applications Development .........................491
15.1 Introduction to Web Applications ................................................................................................. 491
15.2 Creating a Single-Page ASP.NET Website................................................................................... 496
Tutorial 1: Developing a Simple Web Page: Ice Cream Cost ............................................................... 496
15.3 Introduction to HTML .................................................................................................................. 502
15.4 Working with Web Server Controls.............................................................................................. 506
15.5 Validating Data Using Validation Controls .................................................................................. 517
Exercises ............................................................................................................................................... 522
Chapter 16: Web Development: Multipage and Database Applications.......523
16.1 Accessing Databases from Web Forms ........................................................................................ 523
Tutorial 1: Accessing a Database: Theater Tickets Application ........................................................... 524
16.2 Preserving Data during Postbacks Using View State ................................................................... 538
16.3: Multipage Websites and Session State ........................................................................................ 543
16.4 Setting a Page to Its Previous State ............................................................................................... 551
Exercises ............................................................................................................................................... 557
Appendix A: Binary Files ....................................................................................559
A.1 Writing to Binary Files .................................................................................................................. 559
Tutorial: Working with Binary Files ..................................................................................................... 559
A.2 Reading Binary Files ...................................................................................................................... 560
Appendix B: Creating a Database ......................................................................562
Tutorial: Creating HR Database............................................................................................................ 562
Appendix C: Answers to Review Questions ......................................................564
Appendix D: HTML Elements ............................................................................584
Index ......................................................................................................................586
Preface
Mission of the Text
Welcome to Fundamentals of C# Programming for Information Systems. This book teaches the
fundamentals of programming in C# to provide a solid foundation to build business and other real-world
applications. Programming concepts are discussed in the context of familiar practical applications that use
graphical interfaces.

New to This Edition


A key goal of the new edition was to add significant content so that the book could be used in a two-
course sequence in programming. Four new chapters have been added: Two chapters that provide a
comprehensive introduction to web applications development, and two other chapters on the concepts and
practice of object-oriented programming, including inheritance.
Several other updates were made based on feedback from instructors: a second set of three comprehensive
assignments (in chapters 3, 8, and 12), additional end-of-chapter exercises, and learning objectives for
each chapter.

Target Audience
This book is designed for introductory programming courses in IS/MIS, CIS and IT. This book also
would fit into a computer science curriculum with an introductory course that uses a GUI-based
application-oriented approach to teach programming concepts. The breadth and depth of coverage makes
this book suitable for a two-course sequence, particularly when students come to the first course with no
programming background and a slower pace is desired. An approach in a two-course sequence would be
to do in-depth coverage of topics like collections, databases, object-oriented programming, web
development, and others presented in later chapters only in the second course.

Key Features
A key feature of the book is that programming concepts are introduced in small chunks through examples
and illustrations accompanied by hands-on tutorials. The tutorials, which are interspersed with the
concepts, help students apply and explore what they learn immediately. Additionally, review questions
and exercises within the chapters enhance student interest and learning.
Although the book is written for beginners, it is thorough and concise. Graphical illustrations and
screenshots are used throughout the book to enhance learning for both beginners and experienced
students.
Windows forms are used from the beginning to provide GUI-based as opposed to console-based interface.
This book builds graphical user interfaces and code in the .Net environment using Visual Studio. You are
encouraged to use the current free version, Visual Studio Community 2017. Earlier versions, including
Visual Studio 2015, Visual Studio Express and Visual Studio 2013, generally work well, except that you
won’t be able to run a few programs that use certain features available only in C# version 7.1 or greater.
ii

Supplements
For Students: Tutorial_Starts.zip file that contains
o Partially completed projects for tutorials
o Data files/databases used in projects

You may download the Tutorial_Starts.zip file from


http://www.prospectpressvt.com/titles/c-sharp-programming/student-resources/

For Instructors: Instructor resources include


o Completed tutorials
o PowerPoint slides for all chapters
o Test bank
o Partially completed projects for tutorials
o Data files/databases used in projects

To access instructor resources, please complete the request form at


http://www.prospectpressvt.com/faculty-resources/instructors-material/

Installing Visual Studio


You may download Visual Studio Community 2017 from the following website:
https://www.visualstudio.com/downloads/

To install Visual Studio, open the downloaded .exe file and run it.

Overview of the Content and Organization


Every possible sequence of topics seems to put constraints on the quality of illustrative examples and
applications that can be used in a chapter. The organization of chapters in this book attempts to minimize
such problems and to enhance the ability to build on prior chapters. However, except for the foundational
Chapters 1–5, there is significant flexibility in choosing specific topics and the depth of coverage. As
suggested by the dependencies summarized below, there is some flexibility in the sequencing too.
Chapters 1–5 cover the Visual Studio environment and introductory programming concepts, including
methods. These chapters, which provide the foundational knowledge, should be covered in sequence
before other chapters, though certain topics like working with dates and times (section 2.4) may be
postponed or skipped.
Chapter 6 presents the application of the GUI controls ScrollBars, RadioButtons, CheckBoxes,
ComboBoxes and ListBoxes.
Chapter 7 provides a detailed presentation of one-dimensional arrays, and Chapter 8 presents accessing
sequential files and using arrays in combination with files. Chapter 6 is not a prerequisite for Chapters 7
or 8. GUI is presented early on in Chapter 6 to motivate students with more interesting graphical
interfaces. It should be noted that the comprehensive assignment (Assignment 2) specified at the end of
Chapter 8 requires the use of several GUI controls.
Chapter 9 introduces collections, and discusses the List and Dictionary collections in more detail. Chapter
8 (“Sequential Files and Arrays”) is a prerequisite for this chapter. Because of the close relationship
iii

between collections and arrays, collections are presented in this book immediately following Chapter 8 on
arrays.
Chapter 10 discusses the application of ListView and TabControl. The dependency of this chapter on
Chapter 9 (“Collections”) is very low. The prerequisite for this chapter includes Chapters 6 and 8.
Chapter 11 presents multiform applications, Menus and ToolStrips. This chapter has some dependency on
previous chapters, except Chapter 10.
Chapter 12 provides in-depth coverage of accessing databases from C# programs. Chapter 6 is a
prerequisite for this chapter. In addition, the ListView control presented in Chapter 10 is used in an
example in the last part of this chapter, and it is required in the third comprehensive assignment
(Assignment 3) at the end of this chapter. Assignment 3 also requires the use of MainMenu control
discussed in Chapter 11. Other than that, the dependence of Chapter 12 on Chapters 7–11 is relatively
low.
Chapter 13 provides an introduction to object-oriented programming (OOP) principles and techniques.
The initial part of this chapter may be used for an introduction to OOP early in the semester.
Chapter 14 describes the concept of inheritance, implementation of inheritance, subclasses and super
classes, overriding methods and polymorphism. Chapter 13 is a prerequisite for this chapter, and it also
relies on collections from Chapter 9.
Chapter 15 presents the concepts of web applications development, and develops simple web applications
using the ASP.Net platform in the Visual Studio environment. Only the basic programming knowledge
presented in Chapters 1–3 is required for this chapter.
Chaper 16 describes how to access SQL Server databases and develop multipage web projects. Basic
programming concepts presented in Chapters 1–6, the concept of collections from Chapter 9, and basic
database concepts including binding controls to a database and filtering records (Chapter 12) are used in
building the application.
iv

Acknowledgments
I am thankful for the valuable assistance provided by many people in the preparation of this book. I wish
to thank Dr. Jakob Iversen, The University of Wisconsin–Oshkosh, for authoring Chapters 13 and 14 on
Object-Oriented Programming.
I was fortunate to work with Beth Lang Golub, editor and president of Prospect Press, who was flexible
and supportive of my goal to offer a good quality programming textbook at a reasonable price. Special
thanks go to Susan Hegedus, Kathy Bond Borie and Rachel Paul for their painstaking attention to detail in
editing this book, and to Annie Clark for the cover design.
I wish to acknowledge the contributions of the following reviewers for their valuable guidance in
improving the presentation and contents of this book:
Janet Bailey, University of Arkansas at Little Rock
Wei Kian Chen, Champlain College
Clinton Daniel, University of South Florida
Silvana Faja, University of Central Missouri
Joni L. Jones, University of South Florida
David Pumphrey, Colorado Mesa University
Manonita M. Ratwatte, University of Oklahoma (Retired)
Theadora Ross, University of Arkansas at Little Rock
David M. Weber, Northern Arizona University
Thanks are also due to the instructors who provided valuable feedback on the first edition of this book
through user surveys:
Janet Bailey, University of Arkansas, Little Rock
Jeff Dickson, Oregon Institute of Technology
Ruth Lamprecht, Virginia Union University
Panos Linos, Butler University
Ziping Liu, Southeast Missouri State University
Robert Pilgrim, Murray State University
Kris Rosenberg, Oregon Institute of Technology
Doug Titus, University of North Florida

About the Author


Dr. George Philip is Professor Emeritus of Information Systems at the College of Business, The
University of Wisconsin–Oshkosh. He has more than twenty-five years of teaching and consulting
experience in the information systems field, including computer programming in multiple languages. He
also served as chair of the Information Systems Team, and director of the M.S. in Information Systems
program. He has published numerous articles in this field.
Chapter 1

Introduction to Visual Studio and Programming

Welcome to programming in C# language. In this chapter, you will learn to develop simple programs in
the Visual Studio development environment, and to work with different types of data.
Learning Objectives
After studying this chapter, you should be able to:
 Identify the inputs, processes and outputs of a software system.
 Describe the steps involved in developing a computer program.
 Describe the terms: syntax, logic and runtime errors, machine language, low-level language, high-
level language, compiler and interpreter.
 Develop a simple form in Visual Studio to accept user input, do calculations and display
formatted output.
 Work with Label, TextBox, Button, ListBox and MessageBox.
 Develop simple programs that use constants, variables and expressions.
 Use try-catch method to catch errors.

Topics

1.1 Introduction to Programming 1.8 Working with Variables


1.2 Introduction to Visual Studio 1.9 Doing Calculations
1.3 Visual Studio Environment 1.10 Formatting and Displaying Output in a Label
1.4 Adding Controls to a Form 1.11 Additional Concepts: Constants, Scope of
1.5 The Code Editor Window Variables and ListBox
1.6 Introductory Programming Concepts 1.12 Exception Handling: Catching Errors
1.7 Data Types

1.1 Introduction to Programming


Programming is the process of developing computer programs. If a computer program seems like a
mystery to you, it is just a set of instructions telling the computer how to do a task, like looking up the
price of an item or finding the Chinese restaurants in a city.
Unfortunately, computers cannot understand normal English. So, programs have to be written using
special commands and statements according to strict rules. A key aspect of programming is breaking
down what you want the computer to do, into detailed instructions. Like the directions that a GPS gives
you to get to a place, the instructions in a program need to be precise.

Fundamentals of C# Programming for


Information Systems
2 1.1 Introduction to Programming

Typically, a program uses one or more data items to produce some results. For example, a program that
processes an order might use the item number and order quantity to compute the subtotal, sales tax and
total cost, as represented in Figure 1-1.

Figure 1-1: Inputs, process and outputs of a program

Subtotal
Item# Process
Sales tax
Quantity Order
Total cost

The program, represented by the block “Process Order,” may include multiple subtasks like look up the
unit price, check inventory and compute results.
The data that are used by a program are called the input to the program, and the results produced are
called the output of the program. In addition to processing input data to produce the output, a program
might write data to and read data from storage devices like a flash drive or a hard drive, as represented in
Figure 1-2.

Figure 1-2: A general representation of a software system

How Do I Go About Developing a Program?


To understand the process of developing a program, let’s use a simplified order-processing system as an
example. To develop good programs and do so efficiently, follow these steps:
1. Define the purpose, and identify the input, process and output of the program.
2. Design and develop the graphical user interface (GUI).
3. Identify the components and logic of the program.
4. Design and develop files/databases, if any.
5. Write and test the code.
Let’s look at these steps in more detail.

1. Define the purpose, and identify input/process/output


Before you can write the program, you need to lay some groundwork. In this step, you identify what the
user wants the program to do, including the input, process and output of the program.
Depending on the size and complexity of the program, this could involve extensive analysis of the
requirements, including interviews with users; examination of current forms, reports and transactions; and
identifying processes like checking inventory and looking up price in an order.

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 3

Here is an example of a simplified statement of the purpose of the order processing program:
Purpose: Compute and display the subtotal, sales tax and total cost for an order
The output of the program often follows from the purpose. For this example, the output would be
Output: subtotal, sales tax, total cost
The process specifies not only what the program should do (e.g., compute total cost) but also how it
should be done (e.g., how to compute total cost), as follows:
Process: (What?) Look up unit price, look up sales tax rate,
compute subtotal, sales tax and total cost
(How?) subtotal: unit price * order quantity
sales tax: subtotal * sales tax rate
total cost: subtotal + sales tax

Specifying the process also would include identifying the sources of data, like the product file to get the
unit price and sales tax file to get the sales tax rate.
The input specifies the data items that are needed to carry out the process to produce the output. The
input for this order-processing system would be
Input: item number, order quantity
Note that unit price and sales tax rate are not included in the input because the program looks them up. A
real-world system would be a lot more complex. Typically, the process would include additional subtasks
like handling orders when inventory is insufficient, and output may include various reports. In such
systems, graphical methods like Data Flow Diagrams and UML diagrams are used to represent the
processes and the data accessed by them.

2. Design and develop the graphical user interface (GUI)


After identifying the input, process and output of a program, you design and create the user interface—
that is, how the user would interact with the program, and how the program would communicate with the
user. This is the fun part where you bring in your creativity.
Typically, you use forms to interact with the program. As you will learn in the next section, forms have
various types of objects, called controls, such as Button, TextBox and Label. In this step, you identify the
type of controls to be used, specify their names and captions as appropriate, and design the layout. Figure
1-3 shows an example of the GUI for a simplified order-processing system where the user doesn’t provide
the unit price and sales tax rate.

Fundamentals of C# Programming for


Information Systems
4 1.1 Introduction to Programming

Figure 1-3: GUI for an order-processing system

3. Identify the components and logic of the program


This step identifies the major subtasks of the program. For example, in order to process an order, the
program needs to do the following subtasks:
Get Item# and quantity
Look up unit price and tax rate
Compute subtotal, sales tax and total cost
Display subtotal, sales tax and total cost

Again, a real-world program may have to do additional subtasks, like checking the inventory to make sure
there is sufficient quantity on stock.
For relatively simpler programs, after identifying the subtasks, you may go directly to writing the
program for each subtask. However, for tasks involving more complex logic, it might help to develop an
outline of the logic of performing the subtasks. The representation of the logic of a program in plain
English is called pseudo code. You also may represent the logic graphically using a flowchart, as
discussed in Chapter 3.

4. Design and develop files/databases


If data is read from or written to files and/or databases, these are designed and developed prior to writing
the program. Depending on the application, this step may have to be done in parallel with previous steps.

5. Write and test the code


The final step is to write and test the code. You can program in a variety of languages. C#, Java, Visual
Basic, Python and PHP are among the popular languages. You will use C#, which is a popular language
for developing desktop and web applications.
Programing may involve iteratively developing an application by going through the above steps multiple
times.

Syntax, Logic and Runtime Errors


The programming statements you write have to follow strict rules of the language, called the syntax. The
program wouldn’t compile if it had any syntax error, like a missing semicolon at the end of a statement
or a misspelled key word. Compiling is the process of translating the program you write, called the

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 5

source code, to another language before running a program, as described in the next section. So, your
first task is to make sure that there are no syntax errors. The good news is that Visual Studio provides a
lot of help in identifying syntax errors.
After the syntax errors are eliminated, the program may run. But, it’s still too early to celebrate because
the results could be incorrect due to errors in the program logic, just like you can write a grammatically
correct sentence that doesn’t convey the intended message. Errors that cause a program to produce
incorrect or unintended results are called logic errors. A tax-filing software using the wrong tax rate and
a billing software overcharging a customer are examples of logic errors.
There are errors other than logic errors that can occur at runtime. These are called runtime errors.
Runtime errors cause the program to crash (unless the program catches and handles such errors) because
the program asks the computer to do something it is unable to do, like accessing a file with an invalid path
or dividing a number by zero.
The process of identifying errors (bugs) is called debugging. Testing programs to identify and eliminate
errors is an extremely important part of developing software.

Review Questions
1.1 Consider Google as a software system. What would be the input, process and output for Google?
1.2 Consider a software system that enrolls students into classes. Identify some key inputs that the
system needs every time a student enrolls in a class, and the subtasks (process) that need to be
performed. What are some outputs the system should produce for students and instructors?
1.3 List the major steps in developing a program.
1.4 Incorrect punctuation in a program is an example of what type of error?
1.5 A payroll program uses the wrong formula to compute overtime pay. What type of error is it?
1.6 True or false: A program that doesn’t have any syntax errors should produce the correct results.

1.2 Introduction to Visual Studio


In this section, you will learn how to use Visual Studio (VS) to create the user interface and write C#
programs. Visual Studio is an integrated development environment (IDE) for developing applications in a
variety of languages, including C#, Visual Basic, C++, Python and HTML/JavaScript. VS supports
development of desktop and web applications for Windows, Android and iOS. A major strength of Visual
Studio is that it provides a user-friendly environment for developing applications.

Installing Visual Studio


You may download Visual Studio Community 2017 from the following website:
https://www.visualstudio.com/downloads/
To install Visual Studio, open the downloaded vs_community.exe file. The installation software will
guide you through the process. The first time you start Visual Studio, you will be asked to choose the
Development Settings and a Color Theme. Choose Visual C# for settings. You may change these settings
later, as described in Tutorial 1.

Fundamentals of C# Programming for


Information Systems
6 1.2 Introduction to Visual Studio

Components of Visual Studio


Though you have the choice to write programs in a variety of languages, the CPU can understand only
Machine Language, which is extremely difficult for humans to understand. Machine Language requires
detailed instructions that consist of patterns of bits (0 and 1), like 10001010, and are dependent on the
machine (the specific type of computer). Because of the need to write detailed machine-dependent
instructions, Machine Language is called a low-level language.
Except in special cases, programs are written in high-level languages, like C#, which require fewer
statements, are less dependent on the hardware and are easier to understand because they use words rather
than patterns of bits.
Programs written in high-level languages are translated to Machine Language before they are run.
Different languages use different methods to translate and run programs. Many languages use a special
software called a compiler to translate the source code to Machine Language. The compiler typically
produces a separate executable Machine Language program that can be run any number of times without
having to compile every time it is run.
Some programming languages use an interpreter that translates each statement to Machine Language
and runs it without producing an executable program. So, every time the program is run, it needs to be
translated to Machine Language.
Visual Studio uses a compiler, but it translates the source code to an intermediate language, which is
translated to Machine Language and run using another software, as described later in this section. Thus,
Visual Studio translates your statements to Machine Language in two steps:
First, a compiler converts the source code into a language called Microsoft Intermediate Language (IL).
The compiled code, along with references to prebuilt programs (called classes), is stored in an executable
file called Microsoft Intermediate Language (IL) Assembly. Such files have the extension .exe or .dll.
Next, another software called Common Language Runtime (CLR) translates the assemblies from
Intermediate Language to Machine Language and executes the programs. The process of translating and
running the source code may be represented as follows:

The products that support developing and running programs within the Visual Studio family include the
following:
1. An Integrated Development Environment (IDE)
An IDE provides an environment to develop programs, which includes code editors for Visual
C#, Visual Basic, Visual J#, Visual C++, HTML and XML, and designers for Windows forms
and web forms.
In Visual Studio, a software application typically is organized into Projects that may contain one
or more forms.
Forms provide the user interface that allows users to input data for the program, to interact with
the program and to display results.

2. A compiler that translates the source code into Microsoft Intermediate Language (MSIL)

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 7

3. .Net Framework, which includes


a. the Common Language Runtime (CLR) that translates the assemblies from Intermediate
Language to Machine Language and executes the programs, and
b. .Net Framework Class Library that includes a large number of prebuilt programs called
classes.

Running a program, as described earlier, consists of (1) the compiler translating the source code (the
project) into Microsoft Intermediate Language Assembly and (2) the Common Language Runtime
translating the assemblies from Intermediate Language to Machine Language and executing the program
to produce the output. Next, we will look at how to work with Visual Studio to develop C# programs.

Review Questions
1.7 What is the only programming language that the CPU can understand?
1.8 What is a compiler?
1.9 What is an interpreter?
1.10 What is Microsoft Intermediate Language Assembly?
1.11 What is the function of Common Language Runtime in Visual Studio?

Creating an Application in Visual Studio


To become familiar with the Visual Studio environment, let’s create an application for an ice cream
parlor, consisting of a simple Windows form to compute and display the cost for an order of ice cream.
We will follow the five steps identified earlier to develop it:

1. Define the purpose


Purpose: Compute and display the total cost for an order of ice cream
Input: Unit price, number of scoops
Process: Compute total cost
Total cost: unit price * number of scoops
Output: Total cost

2. Design and develop the Graphical User Interface (GUI)

Figure 1-4 presents the design of the form that shows the user interface to let the user enter the number of
scoops and unit price to display the cost. You will create the form in Tutorial 1.

Fundamentals of C# Programming for


Information Systems
8 1.2 Introduction to Visual Studio

Figure 1-4: Windows form to compute ice cream cost

3. Identify the components and logic of the program


The major subtasks include
Get number of scoops and unit price
Compute cost
Display cost

4. Design and develop files/databases


This application doesn’t involve the use of files or databases.

5. Write and test the code


To understand the process of developing the entire application, including the code, let’s create the form
presented in step 2 and write the code for the tasks identified in step 3.

Creating a Windows Form


In Visual Studio, forms are created within a Project. Typically, all forms within a Project relate to a
common task. Creating a project also creates a Solution, which is a container for one or more projects.
Each project we discuss in this book is in a separate solution that has the same name as the project.
Tutorial 1 creates the project and the form to compute the cost of an order of ice cream.

Fundamentals of C# Programming for


Information Systems
Chapter 1: Introduction to Visual Studio and Programming 9

Tutorial 1: Creating a Form: Ice Cream Cost


Step 1-1: Open Visual Studio Community 2017. You will see the start page, shown in Figure 1-5.

Figure 1-5: Visual Studio Start Page

First, you will change some settings.

Changing default settings in Visual Studio


Step 1-2: Change the default folder to save your projects:
Select Tools, Options. Expand Projects and Solutions and select Location.
For Projects Location, select a folder (e.g., your flash drive) where you will save your projects.
Step 1-3: Change the setting to automatically save projects when they are created:
Select General from Projects and Solutions.
Make sure that the CheckBox for Save new projects when created is checked. Click OK.

You may change the color theme by selecting Environment, General from the Options window.
Similarly, you may reset your settings by selecting Tools, Import and Export Settings, Reset all
Settings.
Close Options window.

Fundamentals of C# Programming for


Information Systems
10 Tutorial 1: Creating a Form: Ice Cream Cost

Creating a new project


Step 1-4: Create a new project:
Click Create New Project on the Start page.
You will see the New Project window displayed in Figure 1-6.

Figure 1-6: New Project window

Select Visual C# from Templates, Other Languages. For the type of application, select Windows
Forms Application, as shown in Figure 1-6.
For Name, enter Ch1_IntroProgramming.
Select the Location, if different from the default folder.
Leave the CheckBox for Create directory for solution unchecked so that both the Project and the
Solution will be created in the same folder. (If there are multiple Projects within a Solution, it
would be better to have separate directories for the Solution and Projects.) Note that the default
name for the Solution is the same as that of the Project.) Click OK.
The Visual Studio development environment appears, as shown in Figure 1-7.

Fundamentals of C# Programming for


Information Systems
Another Random Scribd Document
with Unrelated Content
“Yes, only two lots between. They say he’s raised the biggest crop of
wheat that was ever raised in this town, and has got the
handsomest crop of corn growing.”

“Then Sally mustered up courage to marry him?”

“Marry him! She may thank her stars she got him. Let them talk as
much as they like about his being a harum-scarum fellow. There’s
not a smarter, better-hearted fellow in this place, nor a man of
better judgment. He showed a good deal more sense than our Ben,
who, folks think, is all sense.”

“How, father?”

“Why, Ben built his house, and then set his fire, and liked to have
burned up his house, baby, and all the lumber that went into his
vessel, and did scorch his wife; but this harum-scarum fellow burnt
his land over first, and put something in the ground to live on.”

“They say,” said Mrs. Rhines, “that they are the most affectionate
pair that ever was. Joe thinks there is not her equal in the world.”

“That’s just what he ought to think, wife. I hope it will last, and not
be with them as it was with Joe Gubtail and his Dorcas.”

“How was that?”

“Why, he said, when they were first married, he loved her so well he
wanted to eat her up, and now he wishes he had.”

“I don’t think it will, for they have been fond of each other since
they were children, and ought to be well acquainted.”

“You haven’t said anything about Flour, Captain Rhines,” said Charlie.

“O, he ain’t Flour any longer. He lives in a frame house on his own
land, is Mr. Peterson, has money at interest, can read, write, and
cipher, and is master-calker at Wiscasset.”

“Good! Won’t we go over and see him? Didn’t they cut up some
rusties on Joe when he was married?”

“No.”

“I should have thought the boys would have done something to him
to pay him up for all his tricks, for there’s hardly anybody in town
but has something laid up against him.”

“So should I,” said John. “I should have thought they would have
given him a house-warming, and paid up old scores.”

“I suppose there were good reasons why they didn’t.”

“What were they?”

“One was, that everybody loves and respects his wife; another, that
Joe had been very quiet for a long time before he was married, and
they didn’t quite like to stir him up again, for fear they might get the
worst of it, get into a bear-trap, or he might fire a charge of peas or
salt into them. Joe Griffin isn’t a very safe fellow to stir up.”

“I suppose,” said Charlie, “they thought as I did about the bear at


Pleasant Cove—if you’ll let me alone I’ll let you alone.”

“That’s it.”

“I can tell you some news,” said Mrs. Rhines.

“Let’s have it, mother.”

“Isaac has arrived.”

“Isaac Murch?”

“Yes.”
“And has come back mate,” said the captain.

“Where is he?”

“In Boston; but he’s coming home to stay some time. They’re going
to heave the vessel out, recalk, and overhaul her thoroughly.”

“Where is Henry Griffin?”

“Gone to Liverpool in a snow out of Portland.”

The conversation was now interrupted by the entrance of Fred.


While the boys were greeting and talking with him, Mrs. Rhines and
the girls embraced the opportunity to clear away the table; and
when this necessary duty was accomplished, all drew up, and
formed a happy circle.

“Here we are, all together again,” said John, thrusting his chair
between Charlie and Fred, and taking a hand of each, while Tige,
who could bear “no rival near the throne,” put his nose in John’s lap.

“Now,” said Mrs. Rhines, “we have answered all your questions, and
told you all the news, we should like to have you tell us some; and
first, why did you come afoot? You wrote us you was coming by
water. What has become of the boat, Charlie?”

“Sold her to Mr. Foss. Just before we were going to start, he offered
me twenty-five dollars for her. I asked John what he thought about
it. He said, sell her; ’twould be a great deal better fun to come
through the woods, and camp out; that sailing was nothing new to
us. So we put our things aboard a coaster, took our packs, and
started.”

“And you had rather go through all that than come comfortably in
the summer time, with a fair wind, in a good boat?”
“Yes, father; we had a first-rate time. I can tell you they are going
ahead in Portland, building vessels at a great rate. Congress has
granted money to finish the light on Portland Head, and it’s almost
done.”

“They’ve got wagons and sleighs there,” said Charlie. “They don’t
ride altogether on horseback as they do here. In one of these
wagons a farmer can carry a whole ox, or three or four calves; carry
a barrel of molasses, and two folks ride besides; or eight or ten
bushels of potatoes, and whole firkins of butter. They don’t have to
carry a little, stuck in saddle-bags.”

“I should be afraid they would upset,” said Mrs. Rhines.

“Father, they’ve got the biggest ox-wagons, that haul monstrous


loads of boards, and the wheels have iron hoops on the rims. Our
wheels are all wood.”

“You can’t expect such things, John, in new places. Portland is an


old-settled place.”

“They’ve got a wagon with two horses, that carries the mails and
passengers to Portsmouth, to meet the Boston stage. They’ve got
chaises, lots of them. All the ministers have them; and there’s a
man, just come there from Newburyport, that’s going to make
chaises.”

“Captain Rhines,” said Charlie, “there are big Spanish and English
ships come there after spars.”

“It must be a great place,” said Mary.

“I guess it is. Everybody that lives there says it can’t help being a
great place. They are expecting it will be an awful big place; and
there’s a company getting up to build a wharf clear to the channel,—
O, I don’t dare to tell how long!—with stores on it. They’re going to
call it Union Wharf.”
“Father,” said John, “a man came there lately who wears loose
breeches that come clear to his shoes. They call ’em pantaloons.
Captain Starrett says it’s because he’s spindle-shanked, and wants to
cover his legs up.”

In the course of the afternoon, Captain Rhines put the saddle on the
horse, and sent Elizabeth over to Uncle Isaac’s; and when she
returned, both he and his wife came with her.

“Charlie,” said Captain Rhines, “in the morning you and John must
go and see old Mrs. Yelf.”

“O, sir, I can’t go anywhere or do anything till I see father and


mother.”

“You must see her, because the poor old lady won’t live long, and
she longs to see you. It will take but a few minutes to go over in the
morning, and then John can set you on to the island.”
CHAPTER VII.
CHARLIE AT HOME AGAIN.

The next morning, after making their call upon Mrs. Yelf, greatly to
the old lady’s satisfaction, they started for Elm Island.

Ben and Sally, having been informed by Captain Rhines of the time
at which the boys would start, and of the manner in which they
expected to come, were equally, with him, eagerly expecting their
arrival.

Many times she left her work during the day, and went to the door
to see if they were coming. During the period that had elapsed since
the brief but glorious career of the West Wind, the old dugouts had
either passed into oblivion, or were debased to mere tenders for the
whaleboats, which were kept afloat at their moorings, or even used
as cars (cages) to keep lobsters and clams alive in. Whaleboats had
also increased in numbers, by reason of the impulse given to fishing,
and were frequently seen going to and fro in good weather; and
Bennie, who took every sail, it mattered not in what direction they
were heading, for the Perseverance, Jr., kept his mother in a
constant state of excitement by running into the house, and bawling
out, “Marm, they’re coming! They’re most here!” Ben also frequently,
in the course of the day, swept the horizon with his spy-glass. They
expected the boys would land at Captain Rhines’s first, stop all night,
and then John come over with Charlie. Accordingly he frequently
inspected the cove, and the adjacent shores, and if he manifested
less outward show of interest than his father, it must be attributed to
his sluggish temperament, which was less easily roused, and the fact
that he had more to occupy him, and was just at that time engaged
with his hired man upon a job that interested him exceedingly. He
was at work in his orchard.

When Ben declared that he would make cider yet on Elm Island, it
was no idle boast. He had gone to work in the best possible way to
accomplish his designs. He had, in the first place, burned the land
over, the same season in which the growth was cut, and before it
was dry, on purpose that the fire should not burn too deep, and
consume the vegetable mould down to a barren subsoil. The growth
of wood was also of a kind that was rich in potash, an element in
which the apple, of all the trees of the field, delights. Instead of
waiting till he had taken several crops from the land, the stumps had
decayed, and it was exhausted by many ploughings and plantings,
he set out three hundred grafted trees, of choice fruit, that Mr.
Welch had given him, right in the ashes, and among the stumps.
Wherever a stump interfered with the regularity of the rows, he dug
it up, otherwise set the tree close beside it, and the young tree fed
upon its decaying roots. In addition to this, the soil was filled with
the excrements of sea-fowl, that for centuries had bred upon the
island, and it was abundantly supplied with lime from the shells of
muscles, cockles, and bones of fish with which they fed their young.

The orchard was upon a southern exposure, sheltered by cliffs,


forests, and rising ground from cold and blighting winds, and the
bowlders, sprinkled here and there over the surface of the land,
were granite. Enjoying all these advantages of soil and exposure,
protected with jealous care from the encroachments of cattle, the
trees grew more in one year than they would in one of our old
exhausted fields in four. Ben, excessively proud of them, stimulated
their growth by every means in his power, especially as he expected
Mr. Welch to make him another visit before long, and wanted to
show him what could be done on Elm Island, as he had expressed
some doubts if apple trees would do anything so near the sea.

He was now engaged in burning the weeds and brush, which had
been previously cut and piled up, intending to scatter the ashes
around the roots of the young trees. He was also removing the
stumps, a sharp drought proving very favorable to his operations.
There were a few pine stumps on the piece, which, when not too
near an apple tree, were set on fire, and completely exterminated,
the fire following the roots into the dry soil, and living there
sometimes for weeks.

The greater proportion of the stumps were rock-maple, beech, birch,


and oak. The roots of these had become a little tender, and by
chopping off some of the larger ones, could be upset and wrenched
from the soil with oxen, aided by a pry, to which the great strength
of Ben, supplemented by that of Yelf, was applied. Setting cattle for
a severe pull, and making them do all they know how, seems to
consist in something more than practice. It is a gift, and it was one
that Ben possessed in perfection.

When a lad, before he went to sea, he was considered the best


teamster in town, except Uncle Isaac. It was the same with Charlie,
who had not been accustomed to cattle till he came to the island,
while John Rhines, who had all his life been used to driving oxen,
evinced neither inclination nor capacity for it. As for Robert Yelf, he
couldn’t, to save his life, make four cattle pull together, and always,
when he got stuck, took off the leading cattle. Those who do
possess this gift, like to exercise it: there is to them a strange
fascination in driving oxen, so dull and stupid a business to others. It
was thus with Ben; no music was so sweet to him as the singing of
the links of a chain and the creaking of the bows in the yoke as the
cattle settled themselves for a severe pull, their bellies almost
touching the ground. He had a noble team,—six oxen,—the smallest
ox in the team girthing seven feet three inches, fat and willing. He
had them so perfectly trained, that after attaching them to the
stump, and placing them for a twitch, he and Yelf would apply their
strength to the pry, Ben would speak to the oxen, rip, tear, snap
would go the great roots, out would come the stump, taking with it
earth, stones, and bushes, while Bennie would scream, “Get up,
Star, you old villain!” pounding on the ground with his stick, till he
was red in the face, the baby sitting in his little cart, would crow,
and Sailor bark in concert.

It is often that friends, for whom we have been persistently


watching, surprise us after all, when we least expect them; it was so
in the present instance. Ben was so much occupied in his work that
day (and having been disappointed), that after taking a look in the
morning, he had not again inspected the bay.

As for Sally, after having cooked up a lot of niceties to welcome the


boys, and running to the door to look the greatest part of the time
for three or four days, she concluded that something had delayed
them at Portland, and there was no telling when to look for them.

Since the stump-pulling had commenced, and the fires been started,
Bennie, having changed his playground from the green before the
front door, which commanded a full view of the bay, to the orchard,
was busily employed roasting clams by a fire made under a pine
stump; Sailor was helping him, the cat patiently waiting for her
share of the repast, the baby asleep in the cradle, and Sally busy
getting dinner. Aided by all these circumstances, the boys entered
the cove unperceived, and with all the caution of whalemen
approaching a slumbering whale.

“What a splendid wharf!” whispered Charlie to John, as silently they


crept along the footpath to the house, expecting every moment to
hear an alarm. The hop-vine had covered half the roof, and reached
the chimney in one broad belt of green, the honeysuckle hung in
fragrant festoons around the door and windows; Charlie gave John a
punch, and pointed to them, which was answered by a nod.

The doors were all open, for it was a warm day. Slipping off their
shoes, they passed on to the kitchen. Sally was frying fish in the
Dutch oven, and talking to herself all the while.

“I don’t see what has got those boys: they ought to have been here
a week ago. Here I, and all of us, have been watching, and I have
been cooking, to have something nice for them when they come.
There are the custards, that John likes so well, as sour as swill; the
cake all mouldy, and the chicken pie soon will be. Charlie likes warm
biscuit so well, I thought we should see them when they got to the
other shore, and then I should have time to bake some, and have
them piping hot when they get here; now I don’t know what to do.
There’s that mongrel goose, the first one we have ever killed, Charlie
thought so much of them, and took so much pains to raise them, I
did mean he should help eat the first one. O dear, I wish I hadn’t
killed it; but now it’s killed and cooked we must eat it, or it will spoil;
Charlie ain’t here, nor like to be.”

“Yes, he is, you good old soul you.”

With a scream of delight Sally flung herself on his neck.

“How you started me, you roguish boy, you and John too. Why boys,
where have you been? We’ve been looking more than a week, with
all the eyes in our heads, and you’ve come at last, just as we had
given up.”

“What boat is that at the mooring, mother?”

“One your father built the year after you went away.”

“I’m right glad, for I’ve sold mine in Portland, and was afraid I
shouldn’t have any to sail in. Whose scow is that?”

“Ours; your father and Robert built it.”

“Where is father?”

“Out in the orchard, pulling up stumps.”

“Come, John, let’s go and surprise them.”


In this they were disappointed. Sailor espied them, and gave the
alarm.

“Why, how you’ve grown, you dear child!” cried Charlie, catching
Bennie up in his arms, who came running to meet them.

“I should think somebody else had grown too,” said Ben, taking
them both up, setting Charlie astride one of the near oxen’s back,
with the child in his arms; “but I believe John has grown the most,”
putting his arm around him, with an appearance of great affection.

“What a noble team you’ve got, Ben; are these the same cattle you
had when we went away?”

“Yes, all but them sparked ones on forward; they are twins, and are
seven feet and a half. I went clear to North Yarmouth after them,
and I never have dared to tell how much I gave for them. I’ve never
asked them to do anything yet, but what they’ve done it: that yoke
ain’t fit for them, it’s too narrow between the bow holes, and hauls
upon their necks. Charlie you must make me one.”

“I will, father, I’ll make one that will fit them. But how these apple
trees have grown, I couldn’t have believed it possible.”

“Ah, Charlie, what do you think now about making cider on Elm
Island? In three years more some of these largest apple trees will
begin to bear, and one of these in the garden, that Uncle Isaac gave
you, blossomed last spring.”

“Mother says dinner is ready.”

“How does the goose go, Charlie?” asked Sally, when they were well
entered upon the repast.

“Never tasted anything better in my life,” said he, speaking with his
mouth full.
“I must go now,” said John, when the meal was ended; “I promised
father I wouldn’t stop.”

“No, you won’t go,” said Sally, “till after supper. I baked some
custards for you, and kept them till they were sour. You can’t go till I
bake some more; so it’s no use to talk.”

“We’ll have supper early,” said Ben, “and you can get home before
dark.”

They spent the time till supper in social chat, and in looking at the
crops and improvements that had been made on the island.

Charlie found the swallows had multiplied amazingly, the eaves and
rafters of the barn being filled with long rows of nests.

“What a master slat of fowl” said both the boys.

“I shouldn’t think you ever killed any,” said Charlie.

“We haven’t many,” replied Ben; “we’ve been saving them till you
came.”

“Well Charlie,” said he, as they stood at the shore looking after John,
as he departed, “I suppose Elm Island seems rather a dull place, and
a small affair, after being in such a great place as Portland.”

“Portland!” cried Charlie, in high disdain, “I wouldn’t give a gravel


stone on this beach for Portland, and all there is in it.”

“Nor I either. I suppose to-morrow you’ll want to go over and see


Joe and Uncle Isaac, and go to Pleasant Cove.”

“Not till that orchard is done. I want to drive those oxen. O, father,
won’t we have a good time burning the stumps, putting the ashes
round the trees, making it look neat and nice, and picking up all the
stones?”
“I see,” replied Ben, “you have brought back the same heart you
carried away.”

“Why, father, how could I go right off, when you have got so much
to do, and it is such a nice time to do it? Besides, I haven’t seen the
maple, nor been up in the big pine; and I’ve only just looked over
the fowl, and haven’t taken particular notice of any of them, nor of
the birds; then there’s a leg gone out of mother’s wash-bench, a
latch off the kitchen door, a square of glass broke in the buttery, and
that yoke to be made, and the piece must be cut and put to season.
You must have a better goad, father; it’s a shame to drive such a
team with a beech limb. There’s a tough little white-oak butt, as blue
as a whetstone, in the shop, that Uncle Isaac gave me: I’ll make a
goad of that. Then I mean to make a pair of cart wheels, such as I
saw in Portland, on the Saccarappa teams, and John says he’ll put
tires on them. Why shouldn’t we have things on Elm Island as well
as they up there.”

“If you’re going to do all that, or half of it, you wont get off the
island this month.”

“I don’t know as I shall do it all now, but I’ll begin, and I’ll make the
goad before it’s time to go to work to-morrow. Come, father, let us
go and split up the butt before dark.”

They took the small oak butt, set it on end, Charlie held the axe to
the end of it, Ben struck the pole of the axe with a piece of wood,
and they split it in halves, saved one half for axe handles, and split
the other up fine for goads. Charlie was up betimes in the morning,
made a beautiful goad, scraped it with glass, then rubbed it with
dogfish skin, oiled it, and put a brad in it. It was tough as leather. He
made another for Bennie, Jr. Proudly the little chap strutted beside
Charlie with his goad, kindled fires, heaped the brush and roots on
them, roasted clams, baked potatoes in an oven Charlie made for
him, and blessed his stars that Charlie had come.
Before two days Charlie had cut down an elm, roughed out a yoke,
bored the bow-holes, and put it up in the smoke-hole to season, to
be smoothed by and by. He counted sixteen partridges among the
yellow birches, but by Ben’s advice abstained from killing any till
they should have increased in numbers.

“Let them alone, and give them a chance to lay and breed another
spring and summer,” said Ben, “and then we can shoot as many as
we want to eat, and they will hold their own.”
CHAPTER VIII.
JOE GRIFFIN AT HOUSEKEEPING.

When Ben, Jr. received his goad, made as smooth as glass and fish-
skin could render it, oiled with linseed oil to give it a handsome color
and make it more pliable, he was highly gratified. The youngster,
however, soon ascertained that in one very important respect it was
deficient: there was no brad in it.

The discovery was by no means satisfactory; a goad without a brad,


was no goad at all, and he teased Charlie till he put in one of
considerable length, as sharp as a needle, but told him he must not
stick it into the oxen. It unfortunately happened that this was just
the thing Bennie wanted to do, and wanted the brad for. Charlie
stuck it into the oxen, and he flattered himself that he could perform
equally well. While his father and Yelf were at the pry, he strutted
alongside of Charlie, leaping up and down when it came to a severe
pull, very red in the face, smiting on the ground, and screaming,
“Gee Turk! back Buck! her Spark up, you old villain.”

For a while he amused himself by sticking the brad into chips and
flinging them to a distance, or impaling wood-worms and
grasshoppers; but these amusements soon ceased to be exciting.
The little Mischief longed, but didn’t quite dare, to try it on the oxen;
he at length determined to do or die. Watching his opportunity when
Charlie’s back was turned, he set his teeth, went close to old Turk,
shut both eyes, and jabbed the brad into his thigh the whole length,
with such good will that the blood followed the steel. All around the
scene of labor were great stumps which had been torn from the
ground, some of the pines ten or fifteen feet in circumference,
sitting on their edges, the sharp points of their roots protruding in all
directions. The enraged ox administered a kick that sent Bennie
through a thorn bush, in amongst the jagged roots of a pine stump,
where he was wedged in fast, screaming piteously. There was,
indeed, abundant cause for lamentation; the thorns had torn his
hands and the side of his face, the point of a pine root had gone
through his upper lip, and the skin was scraped from his thigh.

Notwithstanding his fright and wounds, though the blood was


running from his lip and hands, he resolutely refused to be carried to
his mother till he obtained his goad, thoroughly convinced that it
was a real one, and effectual, clung like birdlime to the instrument of
his misfortunes. The next day being rainy, Charlie went to work in
the shop upon a pair of cart wheels, and during the rest of the week
continued to work on them.

When Saturday evening came, Sally said to him, “Now, Charlie, not
another stroke of work shall you do till you’ve been to see Uncle
Isaac, Joe Griffin, and the rest of your friends. Here you’ve been
away going on two years, and come home for a visit, and stick right
down to work the very next day. It’s too bad. Uncle Isaac will think
you don’t care anything about him. I should think you’d want to go
to Pleasant Cove.”

“So I do, mother; but you know father has been alone a great part
of the time, and I wanted to help fix the orchard, get the stuff
sawed out for the wheels, and then I’m going to get Uncle Isaac to
help me make them.”

“Well, when we go over to meeting to-morrow, I shall leave you, and


you must stay till we come over the next Lord’s day, and see all
hands.”

“I will, mother.”

John and Charlie went over to Uncle Isaac’s and staid two days and
nights. There they learned that Isaac, his nephew, was expected
that week. From there they went to Joe Griffin’s. His farm was
situated on a ridge of excellent land that rose gradually from the
water, the summit being covered with a mixed growth, in which
beech largely predominated, succeeded on the declivity by rock
maple, ash, and yellow birch. In front of the house was a cove, with
a point on the south-west side, which sheltered it from winds
blowing from that direction, but was exposed to the north and north-
west winds. The house itself stood within a stone’s throw of the
shore, in the middle of a clearing of about six acres. It was a log
house, of the rudest kind, as Joe thought it very likely he might burn
it up before he got done setting fires. Rude as was its appearance,
the whole scene presented to the eye an aspect of comfort and
plenty. The burn had a noble log fence around it; a magnificent
piece of corn completely surrounded the house and log barn,
growing to the very threshold, leaving only a footpath by which to
reach the house; on the other side, the lot had been sown with
wheat, which was now cut, and large stooks were scattered over the
field.

As the boys approached, they paused in admiration.

“I have seen a good many pieces of corn planted on a burn, but I


never saw anything that would begin with that.”

“Look at the grain,” said Charlie, “don’t that look rich? Well, they’ll
have enough to eat, that’s certain.”

Entering the house, they found Mrs. Griffin at the loom, weaving,
and received a most cordial welcome. The house had but two rooms,
but the roof being sharp, and the house large on the ground, there
was room to put beds in the garret. Skeins of linen and woollen
yarn, hanging up all around the room, attested Sally’s capabilities.

“Where is Joe?” asked Charlie.

“In the woods, on the back end of the lot, falling trees. He goes into
the woods as soon as he can see, and stays as long as he can see.”
“He must make an awful hole in the woods in a week,” said John.

“Have you got any pasture?”

“No; but the cow does first-rate on browse, and what grass grows
on open spots in the woods. Now Joe gives her cornstalks, she does
better than our cows ever did at home in the best pasture.”

“Have you got a pig?” asked Charlie.

“Yes, a real nice one. Come, go look at him. We’ve had milk enough
for him till lately. Now Joe has to buy potatoes for him; but we shall
have corn enough of our own by and by.”

“That you will,” said John. “I don’t see how you get your cow into
the barn. You can’t drive her through this cornfield; it’s all around
the barn.”

“We don’t. I go out in the woods to milk. We’ve got a cow-yard


there; and when it rains Joe milks.”

“You have real nice times—don’t you, Sally?”

“I guess we do, John. We work hard, but we are well and strong:
work don’t hurt us, and we’ve enough to eat. Our place is paid for.
There ain’t a man in the world has a right to ask Joe for a dollar, and
there never was a woman had a better husband. We are just as
happy as the days are long.”

After seeing the pig and hens, the boys said they must go and find
Joe.

“Well, go right to the end of the corn, and you’ll hear his axe. Do
you like coot stew, boys?”

“Don’t we!” said Charlie; “and haven’t had one since we left home.”
“Then you shall have one for supper. Joe shot some coots this
morning.”

The boys proceeded through the woods, guided by the sound of the
axe, and soon perceived their friend through the trees busily at
work. Creeping cautiously on their hands and knees, they succeeded
in approaching within a stone’s throw, and concealing themselves
behind the roots of an upturned tree, observed his movements. For
a long distance in front of him were trees cut partly through, the
white chips covering the ground all around their roots. He was now
at work upon an enormous red oak, with long, branching limbs.
Having finished his scarf on the side next to some partially cut trees,
and which had taken the tree nearly off, he wiped the sweat from
his brow, and with an upward glance at the sun, leaned upon his
axe-handle.

It was evident to the boys that Joe had been chopping trees partly
off during the whole afternoon, and was about to fall the monster
oak on them, in order to make a drive; and as he knew by the sun it
was not far from supper-time, this was the last he intended to cut
before supper. He had evidently done a hard day’s work. The sweat
was dropping from his nose, and his clothes were saturated.
Nevertheless, a smile passed over his features, as he stood with a
foot on one of the great spur roots of his victim, leaning forward
upon the axe-handle, evidently in a very happy frame of mind.

“He’s thinking about that piece of corn,” whispered Charlie, “and


what a nice farm he’ll have when he gets these trees out of the
way.”

“Didn’t you see him looking at the sun? He’s glad it’s most supper-
time, when he can see Sally.”

Joe now resumed his work, and taking hold of the end of his axe-
handle with both hands, delivered long, swinging blows, with the
precision and rapidity of some engine, while the great chips fell from
the scarf, and accumulated in a pile around the roots.

“I told you he wanted to see Sally. Only see that axe go in! How true
he strikes, and what a long-winded creature he is!”

“Won’t that make a smashing when it falls? Such a big tree, and
such long limbs! There it goes! I can see the top quiver!”

Crack! snap! Joe ceased to strike as the enormous bulk tottered for
a moment in the air, then falling upon the trees adjoining, which
were cut nearly off, bore them down in an instant, these in their turn
falling upon others. Beneath this tremendous aggregate of forces,
the forest fell with a roar and crash, as though uprooted by a
whirlwind, the air was filled with branches and leaves, and when the
tumult had subsided, a long, broad path was cut through the dense
forest, with here and there a mutilated stub standing upright amid
the desolation. As the last tree touched the earth, a loud cheer,
mingled with the sound of cracking timber and rending branches.
Turning suddenly around, Joe confronted John and Charlie.

“How are you, old slayer of trees?” cried Charlie.

“First-rate, my little boat-builder,” replied Joe, taking both his hands;


“and how are you, John?”

“Well and hearty.”

“I’m right glad to see you, boys, and take it real kind in you to come
clear up here to visit me. When did you get home?”

“Last week,” said Charlie. “We came over to Uncle Isaac’s, and from
there here. You’ve got a real nice place, Joe. How much land have
you?”

“Two hundred acres. It is well watered and timbered. There’s pine


on the back part, as there is on your’n, and all these lots. Did you
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about testbank and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebooksecure.com

You might also like