Page 36 - Introduction to Programming with Java: A Problem Solving Approach
P. 36

                2 Chapter 1 Introduction to Computers and Programming
Suppose you manage a department store, and you don’t know when to restock the shelves because you have difficulty keeping track of inventory. The solution to the problem is to write a set of instructions that keeps track of items as they arrive at your store and as they are purchased. If the instructions are correct and in a format that is understood by a computer, you can enter the instructions as a program, run the program, and enter item-arrival and item-purchase data as they occur. You can then retrieve inventory information from the computer any time you need it. That accurate and easily accessible knowledge enables you to restock your shelves effectively, and you are more likely to turn a profit.
The first step to learning how to write programs is to learn the background concepts. In this chapter, we teach background concepts. In subsequent chapters, we use the background concepts in explaining the really good stuff—how to program.
We start this chapter by describing the various parts of a computer. We then describe the steps involved in writing a program and in running a program. Next, we narrow our focus and describe the programming language we’ll be using for the remainder of the book—Java. We present step-by-step instructions on how to enter and run a real Java program, so that you’ll be able to gain some hands-on experience early on. We finish the chapter with an optional GUI-track section that describes how to enter and run a graphical user interface (GUI) program.
1.2 Hardware Terminology
A computer system is all the components that are necessary for a computer to operate and the connections
 between those components. There are two basic categories of components—hardware and software. Hard- Apago PDF Enhancer
ware refers to the physical components associated with a computer. Software refers to the programs that tell a computer what to do. For now, let’s focus on hardware.
Our description of a computer’s hardware provides you with the information you’ll need as a beginning programmer. (A programmer is a person who writes programs.) After you master the material here, if you decide you want more, go to Webopedia’s Web site at http://www.webopedia.com/ and enter hardware in the search box.
The Big Picture
Figure 1.1 shows the basic hardware components in a computer system. It shows input devices at the left (keyboard, mouse, and scanner), output devices at the right (monitor and printer), storage devices at the bot- tom, and the CPU and main memory in the center. The arrows in Figure 1.1 represent connections between the components. For example, the arrow from the keyboard to the CPU-main memory represents a cable (a connecting wire) that transmits information from the keyboard to the CPU and main memory. Through- out this section, we explain the CPU, main memory, and all the devices in Figure 1.1.
Input and Output Devices
There are different definitions of an input device, but usually the term refers to a device that transfers infor- mation into a computer. Remember—information going into a computer is input. For example, a keyboard is an input device because when a person presses a key, the keyboard sends information into the computer (it tells the computer which key was pressed).
There are different definitions of an output device, but usually the term refers to a device that transfers information out of a computer. Remember—information going out of a computer is output. For example, a
    




















































































   34   35   36   37   38