CHAPTER 1 Introduction The phrase computer science has a very broad meaning today. However, in this book, we define the phrase as ‘issues related to the computer’. This introductory chapter first tries to find out what a computer is, then investigates other issues directly related to computers. We look first at the Turing model as a mathematical and philosophical definition of computation. We then show how today’s computers are based on the von Neumann model. The chapter ends with a brief history of this culture-changing device . . . the computer. Objectives After studying this chapter, the student should be able to: Define the Turing model of a computer. ❑ Define the von Neumann model of a computer. ❑ Describe the three components of a computer: hardware, data, and software. ❑ List topics related to computer hardware. ❑ List topics related to data. ❑ List topics related to software. ❑ Give a short history of computers. ❑ 2 Introduction 1.1 TURING MODEL The idea of a universal computational device was first described by Alan Turing in 1936. He proposed that all computation could be performed by a special kind of a machine, now called a Turing machine. Although Turing presented a mathematical description of such a machine, he was more interested in the philosophical definition of computation than in building the actual machine. He based the model on the actions that people perform when involved in computation. He abstracted these actions into a model for a computational machine that has really changed the world. 1.1.1 Data processors Before discussing the Turing model, let us define a computer as a data processor. Using this definition, a computer acts as a black box that accepts input data, processes the data, and creates output data (Figure 1.1). Although this model can define the functionality of a computer today, it is too general. In this model, a pocket calculator is also a computer (which it is, in a literal sense). Figure 1.1 A single-purpose computing machine Input data Computer Output data Another problem with this model is that it does not specify the type of processing, or whether more than one type of processing is possible. In other words, it is not clear how many types or sets of operations a machine based on this model can perform. Is it a specific-purpose machine or a general-purpose machine? This model could represent a specific-purpose computer (or processor) that is designed to do a single job, such as controlling the temperature of a building or controlling the fuel usage in a car. However, computers, as the term is used today, are general-purpose machines. They can do many different types of tasks. This implies that we need to change this model into the Turing model to be able to reflect the actual computers of today. 1.1.2 Programmable data processors The Turing model is a better model for a general-purpose computer. This model adds an extra element to the specific computing machine: the program. A program is a set of instructions that tells the computer what to do with data. Figure 1.2 shows the Turing model. In the Turing model, the output data depends on the combination of two factors: the input data and the program. With the same input data, we can generate different output if we change the program. Similarly, with the same program, we can generate different 1.1 Turing Model Figure 1.2 A computer based on the Turing model: programmable data processor Program Input data Computer Output data outputs if we change the input data. Finally, if the input data and the program remain the same, the output should be the same. Let us look at three cases. Same program, different input data Figure 1.3 shows the same sorting program with different input data. Although the program is the same, the outputs are different, because different input data is processed. Figure 1.3 The same program, different data Program 3, 12, 8, 22 Input data Program 14, 6, 8, 12 Input data Sort Computer 3, 8, 12, 22 Output data Sort Computer 6, 8, 12, 14 Output data Same input data, different programs Figure 1.4 shows the same input data with different programs. Each program makes the computer perform different operations on the input data. The first program sorts the data, the second adds the data, and the third finds the smallest number. 3 4 Introduction Figure 1.4 The same data, different programs Program 3, 12, 8, 22 Input data Sort Computer Program 3, 12, 8, 22 Input data Program 3, 12, 8, 22 Input data 3, 8, 12, 22 Output data Add Computer 45 Output data Find smallest Computer 3 Output data Same input data, same program We expect the same result each time if both input data and the program are the same, of course. In other words, when the same program is run with the same input data, we expect the same output. 1.1.3 The universal Turing machine A universal Turing machine, a machine that can do any computation if the appropriate program is provided, was the first description of a modern computer. It can be proved that a very powerful computer and a universal Turing machine can compute the same thing. We need only provide the data and the program—the description of how to do the computation—to either machine. In fact, a universal Turing machine is capable of computing anything that is computable. 1.2 VON NEUMANN MODEL Computers built on the Turing universal machine store data in their memory. Around 1944–1945, John von Neumann proposed that, since program and data are logically the same, programs should also be stored in the memory of a computer. 1.2.1 Four subsystems Computers built on the von Neumann model divide the computer hardware into four subsystems: memory, arithmetic logic unit, control unit, and input/output (Figure 1.5). 1.2 Von Neumann Model Figure 1.5 The Von Neumann model Computer Input / output Input data Arithmetic logic unit (ALU) Memory Output data Control unit Memory Memory is the storage area. This is where programs and data are stored during processing. We discuss the reasons for storing programs and data later in the chapter. Arithmetic logic unit The arithmetic logic unit (ALU) is where calculation and logical operations take place. For a computer to act as a data processor, it must be able to do arithmetic operations on data (such as adding a list of numbers). It should also be able to do logical operations on data, as we will see in Chapter 4. Control unit The control unit controls the operations of the memory, ALU, and the input/output subsystem. Input / output The input subsystem accepts input data and the program from outside the computer, while the output subsystem sends the result of processing to the outside world. The definition of the input/output subsystem is very broad: it also includes secondary storage devices such as disk or tape that stores data and programs for processing. When a disk stores data that results from processing, it is considered an output device: when it reads data from the disk, it is considered an input device. 1.2.2 The stored program concept The von Neumann model states that the program must be stored in memory. This is totally different from the architecture of early computers in which only the data was stored in memory: the programs for their task were implemented by manipulating a set of switches or by changing the wiring system. The memory of modern computers hosts both a program and its corresponding data. This implies that both the data and programs should have the same format, because they are stored in memory. In fact, they are stored as binary patterns in memory—a sequence of 0s and 1s. 5 6 Introduction 1.2.3 Sequential execution of instructions A program in the von Neumann model is made of a finite number of instructions. In this model, the control unit fetches one instruction from memory, decodes it, then executes it. In other words, the instructions are executed one after another. Of course, one instruction may request the control unit to jump to some previous or following instruction, but this does not mean that the instructions are not executed sequentially. Sequential execution of a program was the initial requirement of a computer based on the von Neumann model. Today’s computers execute programs in the order that is the most efficient. 1.3 COMPUTER COMPONENTS We can think of a computer as being made up of three components: computer hardware, data, and computer software. 1.3.1 Computer hardware Computer hardware today has four components under the von Neumann model, although we can have different types of memory, different types of input/output subsystems, and so on. We discuss computer hardware in more detail in Chapter 5. 1.3.2 Data The von Neumann model clearly defines a computer as a data processing machine that accepts the input data, processes it, and outputs the result. Storing data The von Neumann model does not define how data must be stored in a computer. If a computer is an electronic device, the best way to store data is in the form of an electrical signal, specifically its presence or absence. This implies that a computer can store data in one of two states. Obviously, the data we use in daily life is not just in one of two states. For example, our numbering system uses digits that can take one of ten states (0 to 9). We cannot (as yet) store this type of information in a computer: it needs to be changed to another system that uses only two states (0 and 1). We also need to be able to process other types of data (text, image, audio, video). These also cannot be stored in a computer directly, but need to be changed to the appropriate form (0s and 1s). In Chapter 3, we will learn how to store different types of data as a binary pattern, a sequence of 0s and 1s. In Chapter 4, we show how data is manipulated, as a binary pattern, inside a computer. 1.3 Computer Components Organizing data Although data should be stored only in one form inside a computer, a binary pattern, data outside a computer can take many forms. In addition, computers (and the notion of data processing) have created a new field of study known as data organization, which asks the question: can we organize our data into different entities and formats before storing them inside a computer? Today, data is not treated as a flat sequence of information. Instead, data is organized into small units, small units are organized into larger units, and so on. We will look at data from this point of view in Chapters 11–14. 1.3.3 Computer software The main feature of the Turing or von Neumann models is the concept of the program. Although early computers did not store the program in the computer’s memory, they did use the concept of programs. Programming those early computers meant changing the wiring systems or turning a set of switches on or off. Programming was therefore a task done by an operator or engineer before the actual data processing began. Programs must be stored In the von Neumann model programs are stored in the computer’s memory. Not only do we need memory to hold data, but we also need memory to hold the program (Figure 1.6). Figure 1.6 Program and data in memory Program Data Memory A sequence of instructions Another requirement of the model is that the program must consist of a sequence of instructions. Each instruction operates on one or more data items. Thus, an instruction can change the effect of a previous instruction. For example, Figure 1.7 shows a program that inputs two numbers, adds them, and prints the result. This program consists of four individual instructions. 7 8 Introduction Figure 1.7 A program made of instructions 1. Input the first number into memory. 2. Input the second number into memory. 3. Add the two together and store the result in memory. 4. Output the result. Program We might ask why a program must be composed of instructions. The answer is reusability. Today, computers do millions of tasks. If the program for each task was an independent entity without anything in common with other programs, programming would be difficult. The Turing and von Neumann models make programming easier by defining the different instructions that can be used by computers. A programmer can then combine these instructions to make any number of programs. Each program can be a different combination of different instructions. Algorithms The requirement for a program to consist of a sequence of instructions made programming possible, but it brought another dimension to using a computer. A programmer must not only learn the task performed by each instruction, but also learn how to combine these instructions to do a particular task. Looking at this issue differently, a programmer must first solve the problem in a step-by-step manner, then try to find the appropriate instruction (or series of instructions) to implement those steps. This step-by-step solution is called an algorithm. Algorithms play a very important role in computer science and are discussed in Chapter 8. Languages At the beginning of the computer age there was only one computer language, machine language. Programmers wrote instructions (using binary patterns) to solve a problem. However, as programs became larger, writing long programs using these patterns became tedious. Computer scientists came up with the idea of using symbols to represent binary patterns, just as people use symbols (words) for commands in daily life. Of course, the symbols used in daily life are different from those used in computers. So the concept of computer languages was born. A natural language such as English is rich and has many rules to combine words correctly: a computer language, on the other hand, has a more limited number of symbols and also a limited number of words. We will study computer languages in Chapter 9. 1.4 History Software engineering Something that was not defined in the von Neumann model is software engineering, which is the design and writing of structured programs. Today it is not acceptable just to write a program that does a task: the program must follow strict rules and principles. We discuss these principles, collectively known as software engineering, in Chapter 10. Operating systems During the evolution of computers, scientists became aware that there was a series of instructions common to all programs. For example, instructions to tell a computer where to receive data and where to send data are needed by almost all programs. It is more efficient to write these instructions only once for the use of all programs. Thus the concept of the operating system emerged. An operating system originally worked as a manager to facilitate access to the computer’s components by a program, although today operating systems do much more. We will learn about them in Chapter 7. 1.4 HISTORY In this section we briefly review the history of computing and computers. We divide this history into three periods. 1.4.1 Mechanical machines (before 1930) During this period, several computing machines were invented that bear little resemblance to the modern concept of a computer. ❑ In the seventeenth century, Blaise Pascal, a French mathematician and philosopher, invented Pascaline, a mechanical calculator for addition and subtraction operations. In the twentieth century, when Niklaus Wirth invented a structured programming language, he called it Pascal to honor the inventor of the first mechanical calculator. ❑ In the late seventeenth century, German mathematician Gottfried Leibniz invented a more sophisticated mechanical calculator that could do multiplication and division as well as addition and subtraction. It was called the Leibniz Wheel. ❑ The first machine that used the idea of storage and programming was the Jacquard loom, invented by Joseph-Marie Jacquard at the beginning of the nineteenth century. The loom used punched cards (like a stored program) to control the raising of the warp threads in the manufacture of textiles. ❑ In 1823, Charles Babbage invented the Difference Engine, which could do more than simple arithmetic operations—it could solve polynomial equations, too. Later, he invented a machine called the Analytical Engine that, to some extent, parallels the idea of modern computers. It had four components: a mill (corresponding to a modern ALU), a store (memory), an operator (control unit), and output (input/output). ❑ In 1890, Herman Hollerith, working at the US Census Bureau, designed and built a programmer machine that could automatically read, tally, and sort data stored on punched cards. 9 10 Introduction 1.4.2 The birth of electronic computers (1930–1950) Between 1930 and 1950, several computers were invented by scientists who could be considered the pioneers of the electronic computer industry. Early electronic computers The early computers of this period did not store the program in memory—all were programmed externally. Five computers were prominent during these years: ❑ The first special-purpose computer that encoded information electrically was invented by John V. Atanasoff and his assistant Clifford Berry in 1939. It was called the ABC (Atanasoff Berry Computer) and was specifically designed to solve a system of linear equations. ❑ At the same time, a German mathematician called Konrad Zuse designed a generalpurpose machine called Z1. ❑ In the 1930s, the US Navy and IBM sponsored a project at Harvard University under the direction of Howard Aiken to build a huge computer called Mark I. This computer used both electrical and mechanical components. ❑ In England, Alan Turing invented a computer called Colossus that was designed to break the German Enigma code. ❑ The first general-purpose, totally electronic computer was made by John Mauchly and J. Presper Eckert and was called ENIAC (Electronic Numerical Integrator and Calculator). It was completed in 1946. It used 18 000 vacuum tubes, was 100 feet long by 10 feet high, and weighed 30 tons. Computers based on the von Neumann model The preceding five computers used memory only for storing data, and were programmed externally using wires or switches. John von Neumann proposed that the program and the data should be stored in memory. That way, every time we use a computer to do a new task, we need only change the program instead of rewiring the machine or turning hundreds of switches on and off. The first computer based on von Neumann’s ideas was made in 1950 at the University of Pennsylvania and was called EDVAC. At the same time, a similar computer called EDSAC was built by Maurice Wilkes at Cambridge University in England. 1.4.3 Computer generations (1950–present) Computers built after 1950 more or less follow the von Neumann model. They have become faster, smaller, and cheaper, but the principle is almost the same. Historians divide this period into generations, with each generation witnessing some major change in hardware or software (but not in the model). First generation The first generation (roughly 1950–1959) is characterized by the emergence of commercial computers. During this time, computers were used only by professionals. They were locked in rooms with access limited only to the operator or computer specialist. Computers 1.5 Computer Science as a Discipline were bulky and used vacuum tubes as electronic switches. At this time, computers were affordable only by big organizations. Second generation Second-generation computers (roughly 1959–1965) used transistors instead of vacuum tubes. This reduced the size of computers, as well as their cost, and made them affordable to small and medium-size corporations. Two high-level programming languages, FORTRAN and COBOL (see Chapter 9), were invented and made programming easier. These two languages separated the programming task from the computer operation task. A civil engineer, for example could write a FORTRAN program to solve a problem without being involved in the electronic details of computer architecture. Third generation The invention of the integrated circuit (transistors, wiring, and other components on a single chip) reduced the cost and size of computers even further. Minicomputers appeared on the market. Canned programs, popularly known as software packages, became available. A small corporation could buy a package, for example for accounting, instead of writing its own program. A new industry, the software industry, was born. This generation lasted roughly from 1965 to 1975. Fourth generation The fourth generation (approximately 1975–1985) saw the appearance of microcomputers. The first desktop calculator, the Altair 8800, became available in 1975. Advances in the electronics industry allowed whole computer subsystems to fit on a single circuit board. This generation also saw the emergence of computer networks (see Chapter 6). Fifth generation This open-ended generation started in 1985. It has witnessed the appearance of laptop and palmtop computers, improvements in secondary storage media (CD-ROM, DVD, and so on), the use of multimedia, and the phenomenon of virtual reality. 1.5 COMPUTER SCIENCE AS A DISCIPLINE With the invention of computers, a new discipline has evolved: computer science. Like any other discipline, computer science has now divided into several areas. We can divide these areas into two broad categories: systems areas and applications areas. Systems areas cover those areas that directly related to the creation of hardware and software, such as computer architecture, computer networking, security issues, operating systems, algorithms, programming languages, and software engineering. Applications areas cover those that are related to the use of computers, such as databases and artificial intelligence. This book is a breadth-first approach to all of these areas. After reading the book, the reader should have enough information to select the desired area of specialty. 11 CHAPTER 5 Computer Organization In this chapter we discuss the organization of a stand-alone computer. We explain how every computer is made up of three subsystems. We also show how a simple, hypothetical computer can run a simple program to perform primitive arithmetic or logic operations. Objectives After studying this chapter, the student should be able to: List the three subsystems of a computer. ❑ Describe the role of the central processing unit (CPU) in a computer. ❑ Describe the fetch–decode–execute phases of a cycle in a typical computer. ❑ Describe the main memory and its addressing space. ❑ Distinguish between main memory and cache memory. ❑ Define the input/output subsystem. ❑ Understand the interconnection of subsystems and list different bus systems. ❑ Describe different methods of input/output addressing. ❑ Distinguish the two major trends in the design of computer architecture. ❑ Understand how computer throughput can be improved using pipelining. ❑ Understand how parallel processing can improve the throughput of computers. ❑ 92 Computer Organization 5.1 INTRODUCTION We can divide the parts that make up a computer into three broad categories or subsystems: the central processing unit (CPU), the main memory, and the input/output subsystem. The next three sections discuss these subsystems and how they are connected to make a standalone computer. Figure 5.1 shows the three subsystems of a standalone computer. Figure 5.1 Computer hardware (subsystems) Memory Central Processing Unit (CPU) Input / output subsystem 5.2 CENTRAL PROCESSING UNIT The central processing unit (CPU) performs operations on data. In most architectures it has three parts: an arithmetic logic unit (ALU), a control unit, and a set of registers, (Figure 5.2). Figure 5.2 Central processing unit (CPU) Registers R0 R1 R2 ALU Rn PC Control Unit IR Central Processing Unit (CPU) R: Register PC: Program Counter IR: Instruction Register 5.2 5.2.1 Central Processing Unit The arithmetic logic unit (ALU) The arithmetic logic unit (ALU) performs logic, shift, and arithmetic operations on data. Logic operations We discussed several logic operations, such as NOT, AND, OR, and XOR, in Chapter 4. These operations treat the input data as bit patterns and the result of the operation is also a bit pattern. Shift operations We discussed two groups of shift operations on data in Chapter 4: logical shift operations and arithmetic shift operations. Logical shift operations are used to shift bit patterns to the left or right, while arithmetic operations are applied to integers. Their main purpose is to divide or multiply integers by two. Arithmetic operation We discussed some arithmetic operations on integers and reals on Chapter 4. We mentioned that some operations can be implemented more efficiently in hardware. 5.2.2 Registers Registers are fast stand-alone storage locations that hold data temporarily. Multiple registers are needed to facilitate the operation of the CPU. Some of these registers are shown in Figure 5.2. Data registers In the past computers had only a few data registers to hold the input data and the result of the operations. Today, computers use dozens of registers inside the CPU to speed up their operations, because complex operations are done using hardware instead of software. These require several registers to hold the intermediate results. Data registers are named R1 to Rn in Figure 5.2. Instruction registers Today computers store not only data, but also programs, in their memory. The CPU is responsible for fetching instructions one by one from memory, storing them in the instruction register (IR in Figure 5.2), decoding them, and executing them. We will discuss this issue later in the chapter. Program counter Another common register in the CPU is the program counter (PC in Figure 5.2). The program counter keeps track of the instruction currently being executed. After execution of the instruction, the counter is incremented to point to the address of the next instruction in memory. 93 94 Computer Organization 5.2.3 The control unit The third part of any CPU is the control unit. The control unit controls the operation of each subsystem. Controlling is achieved through signals sent from the control unit to other subsystems. 5.3 MAIN MEMORY Main memory is the second major subsystem in a computer (Figure 5.3). It consists of a collection of storage locations, each with a unique identifier, called an address. Data is transferred to and from memory in groups of bits called words. A word can be a group of 8 bits, 16 bits, 32 bits, or 64 bits (and growing). If the word is 8 bits, it is referred to as a byte. The term ‘byte’ is so common in computer science that sometimes a 16-bit word is referred to as a 2-byte word, or a 32-bit word is referred to as a 4-byte word. Figure 5.3 Main memory Address 0000000000 0111001011001100 Contents (values) 0000000001 0000001111001101 0000000010 1110101011101100 1111111111 0000001011111100 Memory 5.3.1 Address space To access a word in memory requires an identifier. Although programmers use a name to identify a word (or a collection of words), at the hardware level each word is identified by an address. The total number of uniquely identifiable locations in memory is called the address space. For example, a memory with 64 kilobytes and a word size of 1 byte has an address space that ranges from 0 to 65 535. Table 5.1 shows the units used to refer to memory. Note that the terminology is misleading: it approximates the number of bytes in powers of 10, but the actual number of bytes is in powers of 2. Units in powers of 2 facilitates addressing. Table 5.1 Memory units Unit Exact Number of Bytes Approximation kilobyte 210 (1024) bytes 103 bytes megabyte 220 (1 048 576) bytes 106 bytes gigabyte 230 (1 073 741 824) bytes 109 bytes terabyte 240 bytes 1012 bytes 5.3 Main Memory Addresses as bit patterns Because computers operate by storing numbers as bit patterns, a memory address is also represented as a bit pattern. So if a computer has 64 kilobytes (216) of memory with a word size of 1 byte, we need a bit pattern of 16 bits to define an address. Recall from Chapter 3 that addresses can be represented as unsigned integers (we do not have negative addresses). In other words, the first location is referred to as address 0000000000000000 (address 0), and the last location is referred to as address 1111111111111111 (address 65535). In general, if a computer has N words of memory, we need an unsigned integer of size log2 N bits to refer to each memory location. Memory addresses are defined using unsigned binary integers. Example 5.1 A computer has 32 MB (megabytes) of memory. How many bits are needed to address any single byte in memory? Solution The memory address space is 32 MB, or 225 (25 × 220). This means that we need log2 225, or 25 bits, to address each byte. Example 5.2 A computer has 128 MB of memory. Each word in this computer is eight bytes. How many bits are needed to address any single word in memory? Solution The memory address space is 128 MB, which means 227. However, each word is eight (23) bytes, which means that we have 224 words. This means that we need log2 224, or 24 bits, to address each word. 5.3.2 Memory types Two main types of memory exist: RAM and ROM. RAM Random access memory (RAM) makes up most of the main memory in a computer. In a random access device, a data item can be accessed randomly—using the address of the memory location—without the need to access all data items located before it. However, the term is confusing, because ROM can also be accessed randomly. What distinguishes RAM from ROM is that RAM can be read from and written to. The CPU can write something to RAM and later overwrite it. Another characteristic of RAM is that it is volatile: the information (program or data) is lost if the computer is powered down. In other words, all information in RAM is erased if you turn off the computer or if there is a power outage. RAM technology is divided into two broad categories: SRAM and DRAM. SRAM Static RAM (SRAM) technology uses traditional flip-flop gates (see Appendix E) to hold data. The gates hold their state (0 or 1), which means that data is stored as long as the power is on and there is no need to refresh memory locations. SRAM is fast but expensive. 95 96 Computer Organization DRAM Dynamic RAM (DRAM) technology uses capacitors, electrical devices that can store energy, for data storage. If a capacitor is charged, the state is 1; if it is discharged, the state is 0. Because a capacitor loses some of its charge with time, DRAM memory cells need to be refreshed periodically. DRAMs are slow but inexpensive. ROM The contents of read-only memory (ROM) are written by the manufacturer, and the CPU can read from, but not write to, ROM. Its advantage is that it is nonvolatile—its contents are not lost if you turn off the computer. Normally, it is used for programs or data that must not be erased or changed even if you turn off the computer. For example, some computers come with ROM that holds the boot program that runs when we switch on the computer. PROM One variation of ROM is programmable read-only memory (PROM). This type of memory is blank when the computer is shipped. The user of the computer, with some special equipment, can store programs on it. When programs are stored, it behaves like ROM and cannot be overwritten. This allows a computer user to store specific programs in PROM. EPROM A variation of PROM is erasable programmable read-only memory (EPROM). It can be programmed by the user, but can also be erased with a special device that applies ultraviolet light. To erase EPROM memory requires physical removal and reinstallation of the EPROM. EEPROM A variation of EPROM is electrically erasable programmable read-only memory (EEPROM). EEPROM can be programmed and erased using electronic impulses without being removed from the computer. 5.3.3 Memory hierarchy Computer users need a lot of memory, especially memory that is very fast and inexpensive. This demand is not always possible to satisfy—very fast memory is usually not cheap. A compromise needs to be made. The solution is hierarchical levels of memory (Figure 5.4). The hierarchy is based on the following: Figure 5.4 Memory hierarchy More costly Fastest Registers Cache memory Main memory Less costly Slowest 5.4 ❑ ❑ ❑ Input/Output Subsystem Use a very small amount of costly high-speed memory where speed is crucial. The registers inside the CPU are of this type. Use a moderate amount of medium-speed memory to store data that is accessed often. Cache memory, discussed next, is of this type. Use a large amount of low-speed memory for data that is accessed less often. Main memory is of this type. 5.3.4 Cache memory Cache memory is faster than main memory but slower than the CPU and its registers. Cache memory, which is normally small in size, is placed between the CPU and main memory (Figure 5.5). Figure 5.5 Cache memory CPU Memory ALU Control Unit Cache Cache memory at any time contains a copy of a portion of main memory. When the CPU needs to access a word in main memory, it follows this procedure: 1. The CPU checks the cache. 2. If the word is there, it copies the word: if not, the CPU accesses main memory and copies a block of memory starting with the desired word. This block replaces the previous contents of cache memory. 3. The CPU accesses the cache and copies the word. This procedure can expedite operations; if the word is in the cache, it is accessed immediately. If the word is not in the cache, the word and a whole block are copied to the cache. Since it is probable that the CPU, in its next cycle, will need to access the words following the first word, the existence of the cache speeds processing. We might wonder why cache memory is so efficient despite its small size. The answer lies in the ‘80–20 rule’. It has been observed that most computers typically spend 80 per cent of their time accessing only 20 per cent of the data. In other words, the same data is accessed over and over again. Cache memory, with its high speed, can hold this 20 per cent to make access faster at least 80 per cent of the time. 5.4 INPUT/OUTPUT SUBSYSTEM The third major subsystem in a computer is the collection of devices referred to as the input/output (I/O) subsystem. This subsystem allows a computer to communicate with 97 Computer Organization the outside world, and to store programs and data even when the power is off. Input/output devices can be divided into two broad categories: nonstorage and storage devices. 5.4.1 Nonstorage devices Nonstorage devices allow the CPU/memory to communicate with the outside world, but they cannot store information. Keyboard and monitor Two of the more common nonstorage input/output devices are the keyboard and the monitor. The keyboard provides input, the monitor displays output and at the same time echoes input typed on the keyboard. Programs, commands, and data are input or output using strings of characters. The characters are encoded using a code such as ASCII (see Appendix A). Other devices that fall in this category are mice, joysticks, and so on. Printer A printer is an output device that creates a permanent record. A printer is a nonstorage device because the printed material cannot be directly entered into a computer again unless someone retypes or scans it. 5.4.2 Storage devices Storage devices, although classified as I/O devices, can store large amounts of information to be retrieved at a later time. They are cheaper than main memory, and their contents are nonvolatile—that is, not erased when the power is turned off. They are sometimes referred to as auxiliary storage devices. We can categorize them as either magnetic or optical. Magnetic storage devices Magnetic storage devices use magnetization to store bits of data. If a location is magnetized, it represents 1, if not magnetized, it represents 0. Magnetic disks A magnetic disk consists of one or more disks stacked on top of each other. The disks are coated with a thin magnetic film. Information is stored on and retrieved from the surface of the disk using a read/write head for each magnetized surface of the disk. Figure 5.6 shows the physical layout of a magnetic disk drive and the organization of a disk. Figure 5.6 A magnetic disk Track Disk Sector Controller 98 Disk Read / write heads a. Disk drive Intertrack gap Intersector gap b. Tracks and Sectors 5.4 ❑ ❑ ❑ Input/Output Subsystem Surface organization. To organize data stored on the disk, each surface is divided into tracks, and each track is divided into sectors (Figure 5.6). The tracks are separated by an intertrack gap, and the sectors are separated by an intersector gap. Data access. A magnetic disk is considered a random access device. In a random access device, a data item can be accessed randomly without the need to access all other data items located before it. However, the smallest storage area that can be accessed at one time is a sector. A block of data can be stored in one or more sectors and retrieved without the need to retrieve the rest of the information on the disk. Performance. The performance of a disk depends on several factors, the most important being the rotational speed, the seek time, and the transfer time. The rotational speed defines how fast the disk is spinning. The seek time defines the time to move the read/write head to the desired track where the data is stored. The transfer time defines the time to move data from the disk to the CPU/memory. Magnetic tape Magnetic tape comes in various sizes. One common type is half-inch plastic tape coated with a thick magnetic film. The tape is mounted on two reels and uses a read/write head that reads or writes information when the tape is passed through it. Figure 5.7 shows the mechanical configuration of a magnetic tape drive. Figure 5.7 Magnetic tape Tape reel Take-up reel Track 1 Tape Block Block Tape Track 9 Read / write head a. Tape drive ❑ ❑ ❑ b. Surface orgnization Surface organization. The width of the tape is divided into nine tracks, each location on a track storing 1 bit of information. Nine vertical locations can store 8 bits of information related to a byte plus a bit for error detection (Figure 5.7). Data access. A magnetic tape is considered a sequential access device. Although the surface may be divided into blocks, there is no addressing mechanism to access each block. To retrieve a specific block on the tape, we need to pass through all the previous blocks. Performance. Although magnetic tape is slower than a magnetic disk, it is cheaper. Today, people use magnetic tape to back up large amounts of data. Optical storage devices Optical storage devices, a relatively recent technology, use laser light to store and retrieve data. The use of optical storage technology followed the invention of the compact disk (CD) used to store audio information. Today, the same technology—slightly improved—is used 99 100 Computer Organization to store information in a computer. Devices that use this technology include CD-ROMs, CD-Rs, CD-RWs, and DVDs. CD-ROMs Compact disk read-only memory (CD-ROM) disks use the same technology as the audio CD, originally developed by Phillips and Sony for recording music. The only difference between these two technologies is enhancement: a CD-ROM drive is more robust and checks for errors. Figure 5.8 shows the steps involved in creating and using a CD-ROM. Figure 5.8 Creation and use of CD-ROMs Land Pit a. Master disc b. Mold Land Pit Land Land Pit Pit Land Pit Pit Plastic or glass Molding material Label Protective layer Reflective layer c. CD-ROM Polycarbonate resin Laser source ❑ ❑ Laser Detector Creation. CD-ROM technology uses three steps to create a large number of discs: a. A master disk is created using a high-power infrared laser that creates bit patterns on coated plastic. The laser translates the bit patterns into a sequence of pits (holes) and lands (no holes). The pits usually represent 0s and the lands usually represent 1s. However, this is only a convention, and it can be reversed. Other schemes use a transition (pit to land or land to pit) to represent 1, and a lack of transition to represent 0. b. From the master disk, a mold is made. In the mold, the pits (holes) are replaced by bumps. c. Molten polycarbonate resin is injected into the mold to produce the same pits as the master disk. A very thin layer of aluminum is added to the polycarbonate to provide a reflective surface. On top of this, a protective layer of lacquer is applied and a label is added. Only this last step needs to be repeated for each disk. Reading. The CD-ROM is read using a low-power laser beam. The beam is reflected by the aluminum surface when passing through a land. It is reflected twice when it encounters a pit, once by the pit boundary and once by the aluminum boundary. The two reflections have a destructive effect, because the depth of the pit is chosen to be exactly 5.4 ❑ ❑ Input/Output Subsystem one-fourth of the beam wavelength. In other words, the sensor installed in the drive detects more light when the location is a land and less light when the location is a pit, so can read what was recorded on the original master disk and copied to the CD-ROM. Format. CD-ROM technology uses a different format than magnetic disk (Figure 5.9). The format of data on a CD-ROM is based on: a. A block of 8-bit data transformed into a 14-bit symbol using an error-correction method called Hamming code. b. A frame made up from 42 symbols (14 bits/symbol). c. A sector made up from 98 frames (2352 bytes). Speed. CD-ROM drives come in different speeds. Single speed is referred to as 1x, double speed 2x, and so on. If the drive is single speed, it can read up to 153 600 bytes per second. Table 5.2 shows the speeds and their corresponding data rates. Table 5.2 CD-ROM speeds ❑ Speed Data rate Approximation 1x 153 600 bytes per second 150 KB/s 2x 307 200 bytes per second 300 KB/s 4x 614 400 bytes per second 600 KB/s 6x 921 600 bytes per second 900 KB/s 8x 1 228 800 bytes per second 1.2 MB/s 12x 1 843 200 bytes per second 1.8 MB/s 16x 2 457 600 bytes per second 2.4 MB/s 24x 3 688 400 bytes per second 3.6 MB/s 32x 4 915 200 bytes per second 4.8 MB/s 40x 6 144 000 bytes per second 6 MB/s Application. The expense involved in creating a master disk, mold, and the actual disk can be justified if there are a large number of potential customers. In other words, this technology is economical if the discs are mass produced. Figure 5.9 CD-ROM format Byte (8 bit) Symbol (14 bit) Frame (42 symbols) Sector (98 frames) 101 102 Computer Organization CD-R Clearly, CD-ROM technology is justifiable only if the manufacturer can create a large number of disks. On the other hand, the compact disk recordable (CD-R) format allows users to create one or more disks without going through the expense involved in creating CD-ROMs. It is particularly useful for making backups. You can write once to CD-R disks, but they can be read many times. This is why the format is sometimes called write once, read many (WORM). ❑ Creation. CD-R technology uses the same principles as CD-ROM to create a disk (Figure 5.10). The following lists the differences: a. There is no master disk or mold. b. The reflective layer is made of gold instead of aluminum. c. There are no physical pits (holes) in the polycarbonate: the pits and lands are only simulated. To simulate pits and lands, an extra layer of dye, similar to the material used in photography, is added between the reflective layer and the polycarbonate. d. A high-power laser beam, created by the CD burner of the drive, makes a dark spot in the dye, changing its chemical composition, which simulates a pit. The areas not struck by the beam become lands. ❑ ❑ ❑ Reading. CD-Rs can be read by a CD-ROM or a CD-R drive. This means that any differences should be transparent to the drive. The same low-power laser beam passes in front of the simulated pits and lands. For a land, the beam reaches the reflective layer and is reflected. For a simulated pit, the spot is opaque, so the beam cannot be reflected back. Format and speed. The format, capacity, and speed of CD-Rs are the same as CD-ROMs. Application. This technology is very attractive for the creation and distribution of a small number of disks. It is also very useful for making archive files and backups. Figure 5.10 Making a CD-R Label Protective layer Reflective layer Dye Simulated pit Polycarbonate resin Laser detector Laser source CD-RW Although CD-Rs have become very popular, they can be written to only once. To overwrite previous materials, a new technology allows a new type of disk called compact disk rewritable (CD-RW). It is sometimes called an erasable optical disk. 5.4 ❑ Input/Output Subsystem Creation. CD-RW technology uses the same principles as CD-R to create the disk (Figure 5.11). The following lists the differences: Figure 5.11 Making a CD-RW Label Protective Layer Reflective Layer Alloy Amorphous (pit) Crystalline (land) Laser detector ❑ ❑ ❑ ❑ Polycarbonate resin Laser source a. Instead of dye, the technology uses an alloy of silver, indium, antimony, and tellurium. This alloy has two stable states: crystalline (transparent) and amorphous (nontransparent). b. The drive uses high-power lasers to create simulated pits in the alloy (changing it from crystalline to amorphous). Reading. The drive uses the same type of low-power laser beam as CD-ROM and CD-R to detect pits and lands. Erasing. The drive uses a medium-power laser beam to change pits to lands. The beam changes a location from the amorphous state to the crystalline state. Format and speed. The format, capacity, and speed of CD-RWs are the same as CD-ROMs. Application. The technology is definitely more attractive than CD-R technology. However, CD-Rs are more popular for two reasons. First, blank CD-R discs are less expensive than blank CD-RW discs. Second, CD-Rs are preferable in cases where the created disk must not be changed, either accidentally or intentionally. DVD The industry has felt the need for digital storage media with even higher capacity. The capacity of a CD-ROM (650 MB) is insufficient to store video information. The latest optical memory storage device on the market is called a digital versatile disk (DVD). It uses a technology similar to CD-ROM, but with the following differences: a. The pits are smaller: 0.4 microns in diameter instead of the 0.8 microns used in CDs. b. The tracks are closer to each other. c. The beam is a red laser instead of infrared. d. DVDs use one to two recording layers, and can be single-sided or double-sided. ❑ Capacity. These improvements result in higher capacities (Table 5.3). 103 104 Computer Organization Table 5.3 DVD capacities ❑ ❑ Feature Capacity Single-sided, single-layer 4.7 GB Single-sided, dual-layer 8.5 GB Double-sided, single-layer 9.4 GB Double-sided, dual-layer 17 GB Compression. DVD technology uses MPEG (see Chapter 15) for compression. This means that a single-sided, single-layer DVD can hold 133 minutes of video at high resolution. This also includes both audio and subtitles. Application. Today, the high capacity of DVDs attracts many applications that need to store a high volume of data. 5.5 SUBSYSTEM INTERCONNECTION The previous sections outlined the characteristics of the three subsystems (CPU, main memory, and I/O) in a stand-alone computer. In this section, we explore how these three subsystems are interconnected. The interconnection plays an important role because information needs to be exchanged between the three subsystems. 5.5.1 Connecting CPU and memory The CPU and memory are normally connected by three groups of connections, each called a bus: data bus, address bus, and control bus (Figure 5.12). Figure 5.12 Connecting CPU and memory using three buses CPU Memory Data bus Address bus Control bus Data bus The data bus is made of several connections, each carrying 1 bit at a time. The number of connections depends on the size of the word used by the computer. If the word is 32 bits (4 bytes), we need a data bus with 32 connections so that all 32 bits of a word can be transmitted at the same time. CHAPTER 20 Social and Ethical Issues In this chapter, we briefly focus on social and ethical issues related to the use of computers and to the Internet as a network of computers. Objectives After studying this chapter, the student should be able to: Define three ethical principles related to the use of computers. ❑ Distinguish between physical and intellectual property and list some types of intellectual property. ❑ Define privacy as related to the use of computers. ❑ Give the definition of a computer crime and discuss types of attacks, motivation for attacks, and how to protect against attacks. ❑ Define hackers and the damage done by them. ❑ 526 Social and Ethical Issues 20.1 ETHICAL PRINCIPLES One of the ways to evaluate our responsibility towards the rest of the world when using a computer is to base our decisions on ethics. Ethics is a very complex subject that would take several books to describe in detail. In this chapter, we discuss only three principles that can be related to our goal, shown in Figure 20.1. Figure 20.1 Three main principles of ethics Moral Rules Ethical Principles Utilization Social Contract 20.1.1 Moral rules The first ethical principle states that when we make an ethical decision, we need to consider if the decision is made in accordance with a universally accepted principle of morality. For example, if we want to illegally access a computer to get some information, we need to ask ourselves if this act is moral. We know that most people in the world do not consider such actions to be moral, which means that we would be ignoring the first principle of ethics if we acted in this way. The first principle of ethics says that we should avoid doing anything if it is against universal morality. 20.1.2 Utilization The second theory of ethics is related to the consequences of the act. An act is ethical if it results in consequences which are useful for society. If a person accesses a bank’s computer and erases customer records, is this act useful for society? Since this action may damage the financial status of the bank’s customer, it is detrimental to society. It does not bring about a good result. It is not ethical. The second principle of ethics says that an act is ethical if it brings about a good result. 20.1.3 Social contract The social contract theory says that an act is ethical when a majority of people in society agrees with it. If someone breaks into somebody else’s house and commits a robbery, does this act receive the approval of a majority of society? Since the answer is negative, this act is not ethical. 20.2 Intellectual Property The third principle of ethics says an act is ethical if a majority of people in society agree with it. 20.2 INTELLECTUAL PROPERTY Most ethical issues in the past were related to physical property. Physical property has been defined and physical property rights have been recognized by society throughout history. If a person has a physical object, such as a computer, the rights to this property are granted to the owner. It has been proved that ignoring physical property rights may affect the three ethical principles discussed above. Modern societies have gone further and have recognized the right to intellectual property. For example, an author should be given the right to benefit from his/her written book. An artist should be given the right to benefit from his/her artwork. However, there are some differences between the two types of property: 1. A physical property cannot be copied; it needs to be manufactured or built. If we need another computer, we need to physically build it. On the other hand, intellectual property can be copied. We can make a copy of a book without rewriting it. 2. Copying intellectual property still leaves the owner with the original. Stealing a computer deprives the owner of its use. 3. The owner of intellectual property is only one person (or a group); many people can have the same physical property. 20.2.1 Types of intellectual property Modern societies have recognized several types of intellectual property: trademarks, trade secrets, patents, and copyright. Trademarks A trademark identifies a company’s product or service. A trademark is an intellectual property right granted by the government for a limited term, but which can be renewed. A trademark is considered intellectual property in that the corresponding product cannot legally be copied by other companies or individuals. Trade secrets A trade secret is the information about a product that is kept secret by the owner. For example, a company can create a product but keep the formula secret. A programmer can create a piece of software, but keep the program code secret. People can use the product or the software, but they do not own the formula or the code. Unlike trademarks, a trade secret does not have to be registered; the owner just has to keep it secret. Patents A patent is a right to a monopoly to use and commercially exploit a piece of intellectual property for a limited period of time. The owner has the right to give or not to give permission 527 528 Social and Ethical Issues to anyone who wishes to use the invention. However, the individual property needs to have certain characteristics such as novelty, usefulness, and the capability of being built. Copyright A copyright is a right to a written or created work. It gives the author the exclusive rights to copy, distribute, and display the work. Copyright arises automatically, and does not need to be applied for or formally registered, but a statement of the creator’s copyright should be mentioned somewhere on the work. 20.3 PRIVACY Today, a large amount of personal information about a citizen is collected by private and public agencies. Although in many cases the collection of this information is necessary, it may also pose some risks. Some of the information collected by government or private companies can be used commercially. In many countries, a citizen’s right to privacy is, directly or indirectly, mentioned in the nation’s constitution. However, there is a conflict between people’s right to privacy and the need to collect information about them. Usually governments create a balance between the two through laws. Some countries have introduced codes of ethics related to the use of computers to collect data, as shown below: 1. 2. 3. 4. 5. 6. Collect only data that are needed. Be sure that the collected data are accurate. Allow individuals to know what data have been collected. Allow individuals to correct the collected data if necessary. Be sure that collected data are used only for the original purpose. Use encryption techniques (discussed in Chapter 16) to accomplish private communication. 20.4 COMPUTER CRIMES For the purposes of this book, we give a simple definition of a computer crime. A computer crime is an illegal act, called an attack, involving any of the following: 1. A computer 2. A computer network 3. A computer-related device 4. Software 5. Data stored in a computer 6. Documentation related to the use of computers 20.4.1 Types of attacks Attacks can be divided into two categories: penetration and denial of service. 20.4 Computer Crimes Penetration attack Penetration in this case means breaking into a system to get access to the data stored in a computer or in a computer network. Penetration can result in changing data directly or injecting viruses, worms, and Trojan horses to alter the data indirectly. Viruses Viruses are unwanted programs that are hidden within other programs (host). When the user executes the host program, the virus takes control and replicates itself by attaching itself to other programs. Eventually, the multitude of viruses may stop normal computer operations. Viruses can also be transferred to other machines through the network. Worms A worm is an independent program which can copy itself and which travels through the network. It is a self-replicating piece of software that can travel from one node to another. It tries to find weaknesses in the system to inflict harm. It can reproduce many copies of itself, thus slowing down access to the Internet or stopping communication altogether. Trojan horses A Trojan horse is a computer program that does perform a legitimate task, but which also contains code to carry out malicious attacks such as deleting or corrupting files. It can also be used to access user passwords or other secret information. Denial of service attack The denial of service is an attack on a computer connected to the Internet. These attacks reduce the capability of a computer system to function correctly or bring the system down altogether by exhausting its resources. 20.4.2 Motives Attacks are made with many different motivations such as political reasons, a hacker’s personal interpretation of computer ethics, terrorism, espionage, financial gain, or hate. 20.4.3 Attack protection Although attacks cannot be avoided easily, there are some strategies that can be applied to reduce the number or impact of the attacks. We describe three strategies briefly. Use physical protection The computer can be physically protected to allow physical access only to trusted individuals. Use protective software Software can be used to protect your data, such as data encryption or the use of strong passwords to access the software. 529 530 Social and Ethical Issues Install strong anti-virus software Strong anti-virus software can control access to the computer when installing new software or accessing Internet sites. 20.4.4 Cost It is obvious that ordinary citizens usually bear the cost of these computer attacks. When private companies spend money on preventing attacks, consumers using their products pay through increased prices. When government organizations spend money to prevent attacks, citizens pay through increased taxes. 20.5 HACKERS The word hacker today has a different meaning than when it was used in the past. Previously, a hacker was a person with a lot of knowledge who could improve a system and increase its capability. Today, a hacker is someone who gains unauthorized access to a computer belonging to someone else in order to copy secret information. Although some of the infiltrations carried out by hackers can be harmless, most countries impose heavy penalties for both harmless and harmful hacking. In most countries, accessing government computers without authorization is a crime. Moreover, in many countries there is a heavy punishment for hackers who access the computers of private institutions, and the simple act of obtaining information from somebody else’s computer is a crime, whether the information is used or not. 20.6 END-CHAPTER MATERIALS 20.6.1 Recommended reading For more details about the subjects discussed in this chapter, the following books are recommended: ❑ Kizza, J. M. Ethical and Social Issues in the Information Age, London: Springer, 2010 ❑ Schneider, M and. Gersting, J. L. Invitation to Computer Science, 7th edition, Boston, MA: Cengage Learning, 2016 ❑ Reynold, C. and Tymann, P. Schaum’s Outline of Principles of Computer Science, New York: McGraw-Hill, 2008 ❑ Long, L and Long, N. Computers, Upper Saddle River, NJ: Prentice-Hall, 1999 20.6.2 Key terms This chapter has introduced the following key terms, which are listed here with the pages on which they first occur: copyright 528 privacy 528 denial of service 529 social contract 526 20.7 ethical principle 526 trademark 527 hackers 530 trade secret 527 intellectual property 527 Trojan horse 529 moral rules 526 utilization 526 patent 527 virus 529 penetration attack 529 worm 529 20.6.3 ❑ ❑ ❑ ❑ ❑ ❑ ❑ Practice Set Summary One of the ways to evaluate our responsibility towards the rest of the world when using a computer is to base our decisions on ethics using the three principles of moral rules, utilization, and social contract. Ethical issues nowadays deal not only with physical property but also with intellectual property. Four different types of intellectual property are trademarks, trade secrets, patents, and copyrights. One major ethical issue of our time is respect of privacy. Computer crime mostly involves penetration or denial of service attacks on computer systems. Computer attacks can be avoided using physical protection, protective software, and anti-virus software. The term hacker today refers to a person or organization that gains unauthorized access to a computer belonging to someone else to copy secret information. 20.7 PRACTICE SET 20.7.1 Quizzes A set of interactive quizzes for this chapter can be found on the book’s website. It is strongly recommended that the student takes the quizzes to check his/her understanding of the materials before continuing with the practice set. 20.7.2 Review questions Q20-1. What are the three principles of ethics discussed in this chapter? Q20-2. What are some differences between a physical and an intellectual property? Q20-3. What are some privacy codes of ethics related to using computers? Q20-4. What is the difference between penetration and denial of service when talking about computer crimes? Q20-5. What are the three ways a malicious person can penetrate a computer belonging to someone else? 531 532 Social and Ethical Issues 20.7.3 Problems P20-1. Assume you have created a piece of software that can be used by many vendors. Is this intellectual property protected by a copyright or a patent? Explain your answer. P20-2. You have created a piece of software for which you want to keep the code secret. Do you need to register this intellectual property? Explain your answer. P20-3. If someone collects data about you without informing you in advance, is this act against your right to privacy? Explain your answer. P20-4. If someone sends you an email that carries a virus, what type of computer crime is committed here? Explain your answer. P20-5. If someone renders an institution’s computer system so busy that it cannot do any more work, what type of computer crime is committed? Explain your answer. P20-6. Explain the difference between a virus and a worm. P20-7. Explain the difference between a virus and a Trojan horse. P20-8. Explain the difference between a worm and a Trojan horse. P20-9. Describe different ways in which you can protect your computer from attacks. P20-10. Explain the damage that a hacker can inflict on a computer system of a financial institution. 1 Creating a Worksheet and a Chart Objectives After completing this module, you will be able to: • Start an app • Format cells in a worksheet • Identify the components of the Microsoft Office ribbon • Create a pie chart • Describe the Excel worksheet • Change a worksheet name and sheet tab color • Enter text and numbers • Change document properties • Use the Sum button to sum a range of cells • Preview and print a worksheet • Enter a simple function • Copy the contents of a cell to a range of cells using the fill handle • Use the AutoCalculate area to display statistics • Correct errors on a worksheet • Use Microsoft Office Help • Apply cell styles Introduction Almost every organization collects vast amounts of data. Often, data is consolidated into a summary so that people in the organization better understand the meaning of the data. An Excel worksheet allows data to be summarized and charted easily. A chart is a graphic element that illustrates data. In this module, you will create a worksheet that includes a chart. The data in the worksheet and chart comprise a budget that contains monthly estimates for each income and expense category. Project: Real Estate Budget Worksheet and Chart The project in this module follows proper design guidelines and uses Excel to create the worksheet and chart shown in Figure 1–1a and Figure 1–1b. The worksheet contains budget data for Frangold Realty. Mrs. Frangold has compiled a list of her projected expenses and sources of income and wants to use this information to create an easy-to-read worksheet. In addition, she would like a pie chart to show her estimated monthly expenses by category. Figure 1–1(a) Real Estate Budget Worksheet Figure 1–1(b) Pie Chart Showing Monthly Expenses by Category EX 1-2 The first step in creating an effective worksheet is to make sure you understand what is required. The person or persons requesting the worksheet may supply their requirements in a requirements document, or you can create one. A requirements document includes a needs statement, a source of data, a summary of calculations, and any other special requirements for the worksheet, such as charting and web support. Figure 1–2 shows the requirements document for the new workbook to be created in this module. Worksheet Title Frangold Real Estate Budget Need A yearly projection of Frangold Realty’s budget Source of data Data supplied by Madelyn Frangold includes monthly estimates for income and expenses Calculations The following calculations must be made: 1. For each month, a total for income and expenses 2. For each budget item, a total for the item 3. For the year, total all income and expenses 4. Net income = Total income - Expenses Why is it important to plan a worksheet? The key to developing a useful worksheet is careful planning. Careful planning can reduce your effort significantly and result in a worksheet that is accurate, easy to read, flexible, and useful. When analyzing a problem and designing a worksheet solution, what steps should you follow? 1. Define the problem, including need, source of data, calculations, charting, and web or special requirements. 2. Design the worksheet. 3. Enter the data and formulas. 4. Test the worksheet. After carefully reviewing the requirements document (Figure 1–2) and making the necessary decisions, the next step is to design a solution or draw a sketch of the worksheet based on the requirements, including titles, column and row headings, the location of data values, and the pie chart, as shown in Figure 1–3. The dollar signs and commas that you see in the sketch of the worksheet indicate formatted numeric values. EX 1-3 CONSIDER THIS Figure 1–2 EX 1-4 Excel Module 1 Creating a Worksheet and a Chart Real Estate Budget Worksheet sketch of worksheet and chart Income January December Total $99,999.99 $99,999.99 $99,999.99 $99,999.99 $99,999.99 $99,999.99 January December Total $99,999.99 $99,999.99 $99,999.99 Total $99,999.99 $99,999.99 $99,999.99 Net $99,999.99 $99,999.99 $99,999.99 Commission Interest Total Expenses Rent Utilities Advertising Website Printing Office Supplies Gas Miscellaneous Monthly Expenses Legend of Expenses Figure 1–3 With a good understanding of the requirements document, an understanding of the necessary decisions, and a sketch of the worksheet, the next step is to use Excel to create the worksheet and chart. Starting and Using Excel What Is Excel? Excel is a powerful spreadsheet app that allows users to organize data, complete calculations, make decisions, graph data, develop professional-looking reports, publish organized data to the web, and access real-time data from websites. The four major parts of Excel are as follows: • Workbooks and Worksheets: A workbook is like a notebook. Inside the workbook are sheets, each of which is called a worksheet. A worksheet is a single sheet in a workbook file that lets you enter and manipulate data, perform calculations with data, and analyze data. Thus, a workbook is a collection of worksheets. Worksheets allow users to enter, calculate, manipulate, and analyze data, such as numbers and text. The terms “worksheet” and “spreadsheet” are interchangeable. • Charts: Excel can draw a variety of charts, such as column charts and pie charts. • Tables: Tables organize and store data within worksheets. For example, once a user enters data into a worksheet, an Excel table can sort the data, search for specific data, and select data that satisfies defined criteria. • Web Support: Web support allows users to save Excel worksheets or parts of a worksheet in a format that a user can view in a browser, so that a user can view and manipulate the worksheet using a browser. Excel web support also provides access to real-time data, such as stock quotes, using web queries. To Start Excel and Create a Blank Workbook Across the bottom of the Windows desktop is the taskbar. The taskbar contains the Start button, a clickable button at in the lower left corner of the Windows 10 screen that you click to open the Start menu. The Start menu provides access to all programs, documents, and settings on the computer. The Start menu may contain one of more folders, and these folders can be used to group related apps together. A folder is an electronic container that helps you organize your computer files, like a cardboard folder on your desk; it can contain subfolders for organizing files into smaller groups. The Start menu allows you to start programs, store and search for documents, customize the computer or mobile device, and sign out of a user account or shut down the computer or mobile device. A menu is a list of related items, including folders, programs, and commands. Each command on a menu performs a specific action, such as saving a file or obtaining help. Why? Commands are one of the principal ways you communicate with an app so you can tell it what you want it to do. The following steps, which assume Windows is running, use the Start menu to start Excel and create a blank workbook based on a typical installation. You may need to ask your instructor how to start Excel on your computer. 1 • Click the Start button on the Windows taskbar to display the Start menu containing a list of apps installed on the computer or mobile device. Start menu scroll box • If necessary, scroll list of apps installed on computer (your list may differ) to display Excel (Figure 1–4). Excel app name Note: To help you locate screen elements that are referenced in the step instructions, such as buttons and commands, this book uses red boxes to point to these screen elements. Start button Figure 1–4 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-5 EX 1-6 Excel Module 1 Creating a Worksheet and a Chart 2 • Click Excel to start the app (Figure 1–5). Microsoft Excel is running Blank workbook thumbnail, or miniature image Figure 1–5 Excel Window 3 • Click the Blank Q&A workbook thumbnail on the Excel start screen to create a blank Excel workbook in the Excel window (Figure 1–6). title bar blank workbook created What happens when I start Excel? Excel provides a means for you to create a blank document, as shown in Figure 1–5. After you click the Blank workbook thumbnail, the Excel Figure 1–6 window shown in Figure 1–6 opens. A window is a rectangular-shaped work area that displays an app or a collection of files, folders, and Windows tools. A window has a title bar, an area at the top of a document window or app window that displays the file name and program name. Other Ways 1. Type app name in search box, click app name in results list 2. Double-click file created in app you want to start The Excel Window The Excel window consists of a variety of components to make your work more efficient and worksheets more professional. These include the worksheet window, ribbon, Tell Me box, Quick Access Toolbar, and Microsoft Account area. Excel opens a new workbook with one worksheet. If necessary, you can add additional worksheets. Each worksheet has a sheet name that appears on a sheet tab, an indicator at the bottom of the window that identifies a worksheet. For example, Sheet1 is the name of the active worksheet displayed in the blank workbook shown in Figure 1–7. You can add more sheets to the workbook by clicking the New sheet button. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-7 Worksheet The worksheet is organized into a rectangular grid containing vertical columns and horizontal rows. A column letter in a box above the grid, also called the column heading, appears above each worksheet column to identify it. A row number in a box on the left side of a worksheet row, also called the row heading, identifies each row. The intersection of each column and row is a cell. A cell is the box, formed by the intersection of a column and a row, where you enter data. Each worksheet in a workbook has 16,384 columns and 1,048,576 rows for a total of 17,179,869,184 cells. Only a small fraction of the active worksheet appears on the screen at one time. A cell is referred to by its unique address, or cell reference, which is the column letter and row number location that identifies a cell within a worksheet, such as A1. To identify a cell, specify the column letter first, followed by the row number. For example, cell reference D5 refers to the cell located at the intersection of column D and row 5 (Figure 1–7). One cell on the worksheet, designated the active cell, is the worksheet cell into which you are entering data. The active cell in Figure 1–7 is A1. The active cell is identified in three ways. First, a heavy border surrounds the cell; second, the active cell reference shows immediately above column A in the Name box; and third, the column heading A and row heading 1 are highlighted so that it is easy to see which cell is active (Figure 1–7). Microsoft account area Quick Access Toolbar Name box ribbon Tell Me box heavy border surrounding active cell column heading L cell D5 gridlines worksheet window row heading 12 highlighted row and column headings indicate cell A1 is active scroll boxes adjusts size of displayed document sheet tab scroll bars New sheet button status bar tab scrolling buttons View buttons; default is Normal view Figure 1–7 scroll arrows EX 1-8 Excel Module 1 Creating a Worksheet and a Chart The evenly spaced horizontal and/or vertical lines used in a worksheet or chart are called gridlines. Gridlines make a worksheet easier to read. If desired, you can turn the gridlines off so that they do not show on the worksheet. While learning Excel, gridlines help you to understand the structure of the worksheet. The pointer appears as a block plus sign whenever it is located in a cell on the worksheet. Another common shape of the pointer is the block arrow. The pointer turns into the block arrow when you move it outside the worksheet or when you drag cell contents between rows or columns. Scroll Bars Scroll bars on the right edge (vertical scroll bar) and bottom edge (horizontal scroll bar) of a document window let you view a document that is too large to fit on the screen at once. You use a scroll bar to display different portions of a document in the document window. On a scroll bar, the position of the scroll box reflects the location of the portion of the document that is displayed in the document window. Status Bar The status bar is the gray bar at the bottom of the Excel window that shows status information about the currently open worksheet, as well as view buttons and zoom controls. As you type text or perform certain tasks, various indicators and buttons may appear on the status bar. The right side of the status bar includes buttons and controls you can use to change the view of a document and adjust the size of the displayed document. Ribbon The ribbon (shown in Figure 1–8) is a horizontal strip near the top of the window that contains tabs (pages) of grouped command buttons that you click to interact with the app. Each tab in the ribbon contains a group of related commands and settings. Each group is a tab element on the ribbon that contains related commands. When you start an Office app, such as Excel, it initially displays several main tabs, also called default or top-level tabs. All Office apps have a Home tab, which contains the more frequently used commands. When you start Excel, the ribbon displays ten main tabs: File, Home, Insert, Draw, Page Layout, Formulas, Data, Review, View, and Help. (If you are using a desktop computer, you might not see the Draw tab.) Home tab arrow button main tabs groups scroll box status bar scroll bar status bar controls Figure 1–8 In addition to the main tabs, Excel displays tool tabs, also called contextual tabs (Figure 1–9), tabs that appear in addition to the main tabs on the ribbon when you perform certain tasks or work with objects, such as pictures or tables. If you insert a chart in an Excel workbook, for example, the Chart Tools tab and its related subordinate Design and Format tabs appear, collectively referred to as the Chart Tools Design tab or the Chart Tools Format tab. When you are finished working with the chart, the Chart Tools tabs disappear from the ribbon. Excel determines when tool tabs should appear and disappear based on tasks you perform. Chart Tools Design tab Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-9 Chart Tools Format tab gallery scroll arrows More button in-ribbon gallery Figure 1–9 Items on the ribbon include buttons and galleries (shown in Figures 1–8 and 1–9). A gallery is a collection of choices, arranged in a grid or list, that you can browse through before making a selection of items such as fonts. You can scroll through choices in a gallery by clicking its scroll arrows. Or, you can click a gallery’s More button to view more gallery options on the screen at a time. Some buttons and boxes have arrows that, when clicked, also display a gallery; others always cause a gallery to be displayed when clicked. Most galleries support live preview, an Office feature that shows the results that would occur in your file, such as the effects of formatting options on a document’s appearance, if you clicked the option you are pointing to (Figure 1–10). Live preview works only if you are using a mouse; if you are using a touch screen, you will not be able to view live previews. Chart Tools Design tab is one of many tool tabs that appear automatically depending on the task you perform as you move pointer from one gallery option to next, Excel shows live preview of chart design in worksheet, so that you can see effect of option in worksheet before selecting it chart changes to style selected in gallery Figure 1–10 EX 1-10 Excel Module 1 Creating a Worksheet and a Chart Some commands on the ribbon display an image to help you remember their function. When you point to a command on the ribbon, all or part of the command glows in a darker shade of gray, and a ScreenTip appears on the screen. A ScreenTip (Figure 1–11) is a label that appears when you point to a button or object, which may include the name, purpose, or keyboard shortcut for the object. It may also include a link to associated Help topics, if any. Some groups on the ribbon have a small arrow in the lower-right corner, called a Dialog Box Launcher, that when clicked displays a dialog box or a pane with more options for the group (Figure 1–12). When presented with a dialog box, you make selections and must close the dialog box before returning to the document. A pane, in contrast to a dialog box, is a section of a window, such as the navigation pane in the File Explorer window, that can remain open and visible while you work in the document. Quick Access Toolbar Touch/Mouse Mode button pointer on Paste arrow ScreenTip for Paste arrow Figure 1–11 clicking Font Dialog Box Launcher displays Format Cells dialog box Font Dialog Box Launcher Font group Figure 1–12 Mini Toolbar The Mini toolbar is a small toolbar that appears automatically next to selected text and that contains the most frequently used text formatting commands, such as bold, italic, font color, and font size (Figure 1–13). If you do not use the Mini toolbar, it disappears from the screen. The buttons, arrows, and boxes on the Mini toolbar may vary, depending on whether you are using Touch mode versus Mouse mode. If you right-click an item in the document window, Excel displays both the Mini toolbar and a shortcut menu, which is discussed in a later section in this module. All commands on the Mini toolbar also exist on the ribbon. The purpose of the Mini toolbar is to minimize hand or mouse movement. Quick Access Toolbar mini toolbar commands on mini toolbar also are on ribbon Quick Access Toolbar The Quick Figure 1–13 Access Toolbar (shown in Figure 1–13) is a customizable toolbar at the left edge of the title bar that contains buttons you can click to perform frequently used commands. The commands on the Quick Access Toolbar always are available, regardless of the task you are performing. If your computer or mobile device has a touch screen, the Touch/Mouse Mode button will appear on the Quick Access Toolbar and will allow you to switch between Touch mode and Mouse mode. If you are primarily using touch gestures, Touch mode will add more space between commands on menus and on the ribbon so that they are easier to tap. While touch gestures are convenient ways to interact with Office apps, not all features are supported when you are using Touch mode. If you are using a mouse, Mouse mode will not add the extra space between buttons and commands. The Quick Access Toolbar is discussed in more depth later in the module. KeyTips If you prefer using the keyboard instead of the mouse, you can display KeyTips for certain commands (Figure 1–14). KeyTips are labels that appear over each tab and command on the ribbon when the ALT key is pressed. To select a command using the keyboard, press the letter or number displayed in the KeyTip, which may cause additional KeyTips related to the selected command to appear. To remove KeyTips from the screen, press the alt key or the esc key until all KeyTips disappear, or click anywhere in the app window. Formula Bar As you type, Excel displays your entry in the formula bar, the area above the worksheet grid where you enter or edit data in the active cell (Figure 1–14). You can make the formula bar larger by dragging the bottom of the formula bar or clicking the expand button to the right of the formula bar. Excel also displays cell information in the Name box, a box to the left of the formula bar that shows the cell reference or name of the active cell. Tell Me Box The Tell Me box is a text box to the right of the ribbon tabs that is used to find a command or to access the Office Help system (Figure 1–14). As you type in the Tell Me box, Excel displays search results that are refined as you type. For example, if you want to center text in a document, you can type “center” in the Tell Me box and then select the appropriate command. The Tell Me box also lists related commands and/or the last five commands accessed from the box. Microsoft Account Area In the Microsoft Account area, an area on the right side of the title bar, you can use the Sign in link to sign in to your Microsoft account (Figure 1–14). Once signed in, you will see your account information. KeyTips appear when you press ALT key on keyboard Tell Me box Microsoft Account area Formula bar Name box Figure 1–14 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-11 EX 1-12 Excel Module 1 Creating a Worksheet and a Chart To Display a Different Tab on the Ribbon The ribbon tab currently displayed is called the active tab. The following step displays the Insert tab; that is, it makes it the active tab. Why? When working with an Office app, you may need to switch tabs to access other options for working with a document. 1 • Click Insert on the ribbon to display the Insert tab (Figure 1–15). Experiment • Click the other tabs on the ribbon to view their contents. • Click the View tab, click the Page Layout tab, and then click the Insert tab again. Insert tab ‘Collapse the Ribbon’ button Insert tab has 9 groups Figure 1–15 Other Ways 1. Press ALT, press letter corresponding to tab to display Selecting a Cell BTW Touch Mode Differences The Office and Windows interfaces may vary if you are using touch mode. For this reason, you might notice that the function or appearance of your touch screen differs slightly from this module’s presentation. To enter data into a cell, you first must select it. The easiest way to select a cell (to make it active) is to use the mouse to move the block plus sign pointer to the cell and then click. An alternative method is to use the arrow keys that are located on a standard keyboard. An arrow key selects the cell adjacent to the active cell in the direction of the arrow on the key. You know a cell is selected, or active, when a heavy border surrounds the cell and the active cell reference appears in the Name box on the left side of the formula bar. Excel also changes the color of the active cell’s column and row headings to a darker shade. Entering Text In Excel, any set of characters containing a letter, hyphen (as in a telephone number), or space is considered text. Text is used for titles, such as column and row titles, on the worksheet. Worksheet titles and subtitles should be as brief and meaningful as possible. A worksheet title could include the name of the organization, department, or a description of the content of the worksheet. A worksheet subtitle, if included, could include a more detailed description of the content of the worksheet. Examples of worksheet titles are January 2021 Payroll and Year 2021 Projected Budget, and examples of subtitles are Finance Department and Monthly Projections, respectively. As shown in Figure 1–16, data in a worksheet is identified by row and column titles so that the meaning of each entry is clear. Rows typically contain information such as categories of data. Columns typically describe how data is grouped in the worksheet, such as by month or by department. cell address worksheet title column button shaded to indicate it contains active cell BTW Screen Resolution worksheet subtitle column titles active cell, F20, appears in the Name box and has heavy border row titles row button is shaded to indicate it contains active cell If you are using a computer to step through the project in this module and you want your screens to match the figures in this book, you should change your screen’s resolution to 1366 × 768. block plus sign Figure 1–16 To Enter the Worksheet Titles As shown in Figure 1–16, the worksheet title, Frangold Real Estate Budget, identifies the purpose of the worksheet. The worksheet subtitle, Monthly Estimates, identifies the type of data contained in the worksheet. Why? A title and subtitle help the reader to understand clearly what the worksheet contains. The following steps enter the worksheet titles in cells A1 and A2. Later in this module, the worksheet titles will be formatted so that they appear as shown in Figure 1–16. 1 • Click Home on the ribbon to display the Home tab. • If necessary, click cell A1 to make cell A1 the active cell (Figure 1–17). heavy border indicates cell A1 is selected Figure 1–17 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-13 EX 1-14 Excel Module 1 Creating a Worksheet and a Chart 2 • Type Frangold Real Estate Budget in cell A1 Q&A (Figure 1–18). Why did the appearance of the formula bar change? Excel displays the title in the formula bar and in cell A1. When you begin typing a cell entry, Excel enables two additional boxes in the formula bar: The Cancel button and the Enter button. Clicking the Enter button completes an entry. Clicking the Cancel button cancels an entry. Enter button formula bar cancel button text in active cell overflows into adjacent cells to the right Figure 1–18 3 • Click the Enter button in the Q&A formula bar to complete the entry and enter the worksheet title (Figure 1–19). Why does the entered text appear in three cells? When the typed text is longer than the width of a cell, Excel displays the overflow characters in adjacent cells to the right as long as those adjacent cells contain no data. If the adjacent cells contain data, Excel hides the overflow characters. The overflow characters are visible in the formula bar whenever that cell is active. Enter button text entered in cell A1 Figure 1 –19 4 • Click cell A2 to select it. • Type Monthly Estimates as the cell entry. • Click the Enter button to complete Q&A the entry and enter the worksheet subtitle (Figure 1–20). What happens when I click the Enter button? When you complete an entry by clicking the Enter button, the insertion point disappears and the cell in which the text is entered remains the active cell. Enter button worksheet subtitle entered in cell A2 Figure 1–20 Other Ways 1. Click any cell other than active cell 2. Press ENTER 3. Press HOME, PAGE UP, PAGE DOWN, END, UP ARROW, DOWN ARROW, LEFT ARROW, or RIGHT ARROW AutoCorrect The AutoCorrect feature of Excel works behind the scenes, where it automatically detects and corrects typing errors. AutoCorrect makes three types of corrections for you: 1. Corrects two initial uppercase letters by changing the second letter to lowercase. 2. Capitalizes the first letter in the names of days. 3. Replaces commonly misspelled words with their correct spelling. For example, it will change the misspelled word recieve to receive when you complete the entry. AutoCorrect will correct the spelling of hundreds of commonly misspelled words automatically. BTW Ribbon and Screen Resolution Excel may change how the groups and buttons within the groups appear on the ribbon, depending on the screen resolution of your computer. Thus, your ribbon may look different from the ones in this book if you are using a screen resolution other than 1366 × 768. To Enter Column Titles The worksheet is divided into two parts, income and expense, as shown in Figure 1–16. Grouping income and expense data by month is a common method for organizing budget data. The column titles shown in row 3 identify the income section of the worksheet and indicate that the income values will be grouped by month. Likewise, row 8 is clearly identified as the expense section and similarly indicates that the expense values will be estimated on a per-month basis. The following steps enter the column titles in row 3. Why? Data entered in columns should be identified using column titles to identify what the column contains. 1 • Click cell A3 to make it the active cell. • Type Income to begin entry of a column title in the active cell (Figure 1–21). active cell reference in Name box changes to A3 Income displayed in formula bar and cell A3 cell A3 is active cell Figure 1–21 Excel Module 1 Why is it difficult to read the text on my screen? If you are having trouble reading the cell values in your spreadsheet, you can zoom in to make the cells larger. When you zoom in, fewer columns and rows display on your screen, and you might have to scroll more often. To zoom in, drag the zoom slider on the right side of the status bar, or click the plus button on the zoom slider, until you reach your desired zoom level. You also can zoom by clicking the Zoom button (View tab | Zoom group), selecting a desired zoom percentage (Zoom dialog box), and then clicking OK (Zoom dialog box). CONSIDER THIS Creating a Worksheet and a Chart Excel Module 1 EX 1-15 EX 1-16 Excel Module 1 Creating a Worksheet and a Chart 2 • Press the RIGHT ARROW key to enter the column title and make Q&A the cell to the right the active cell (Figure 1–22). Why is the RIGHT ARROW key used to complete the entry in the cell? Pressing an arrow key to complete an entry makes the adjacent cell in the direction of the arrow (up, down, left, or right) the next active cell. However, if your next entry is in a nonadjacent cell, you can complete your current entry by clicking the next cell in which you plan to enter data. You also can press ENTER and then click the appropriate cell for the next entry. cell B3 is active cell column title entered Figure 1–22 3 • Repeat Steps 1 and 2 to enter the remaining column titles; that is, enter January in cell B3, February in March in cell D3, April in cell E3, May in cell F3, June in cell G3, July in cell H3, August in cell I3, September in cell J3, October in cell K3, November in cell L3, December in cell M3, and Total in cell N3 (complete the last entry in cell N3 by clicking the Enter button in the formula bar). cell C3, • Click cell A8 to select it. • Repeat Steps 1 and 2 to enter the remaining column titles; that is, enter Expenses in cell A8, January in cell B8, February in cell C8, March in cell D8, April in cell E8, May in cell F8, June in cell G8, July in cell H8, August in cell I8, September in cell J8, October in cell K8, November in cell L8, December in cell M8, and Total in cell N8 (complete the last entry in cell N8 by clicking the Enter button in the formula bar) (Figure 1–23). Enter button column titles left-aligned in cells Figure 1–23 To Enter Row Titles The next step in developing the worksheet for this project is to enter the row titles in column A. For the Frangold Real Estate Budget worksheet data, the row titles contain a list of income types and expense types. Each income or expense item should be placed in its own row. Why? Entering one item per row allows for maximum flexibility, in case more income or expense items are added in the future. The following steps enter the row titles in the worksheet. 1 • Click cell A4 to select it. • Type Commission and then click cell A5 or press the DOWN ARROW key to enter a row title (Figure 1–24). row title, Commission, entered in cell A4 cell A5 is active cell Figure 1–24 2 • Repeat Step 1 to enter the remaining row titles Q&A in column A; that is, enter Interest in cell A5, Total in cell A6, Rent in cell A9, Utilities in cell A10, Advertising in cell A11, Website in cell A12, Printing in cell A13, Office Supplies in cell A14, Gas in cell A15, Miscellaneous in cell A16, Total in cell A17, and Net in cell A19 (Figure 1–25). Why is the text left-aligned in the cells? Excel automatically left-aligns the text in the cell. Excel treats any combination of numbers, spaces, row titles and nonnumeric characters as entered text. For example, Excel would recognize the following entries as text: 401AX21, 921–231, 619 321, 883XTY. How to change the text alignment in a cell is discussed later in this module. Figure 1–25 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-17 EX 1-18 Excel Module 1 Creating a Worksheet and a Chart Entering Numbers In Excel, you enter a number into a cell to represent an amount or value. A number is an amount or value using any of the following characters: 1 2 3 4 5 6 7 8 9 + - ( ) , / . $ E e. The use of special characters is explained when they are used in this book. If you are entering numbers that will not be used in a calculation, you should format those numbers as text. You can format numeric data as text by typing an apostrophe before the number(s). To Enter Numbers The Frangold Real Estate Budget worksheet numbers used in Module 1 are summarized in Table 1–1. These numbers, which represent yearly income and expense amounts, are entered in rows 4–5 and 9–16. Why? One of the most powerful features of Excel is the ability to perform calculations on numeric data. Before you can perform calculations, you first must enter the data. The following steps enter the numbers in Table 1–1 one row at a time. Table 1–1 Frangold Real Estate Budget Worksheet Income January February March Commission Interest 12000 100 Expenses January February March 12000 100 April May June July August September October November December 14000 14000 16000 18500 20000 100 100 100 100 100 18500 100 18500 100 14000 100 14000 100 16500 100 April May June July August September October November December Rent Utilities Advertising Website Printing 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 500 200 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 0 200 1500 325 400 0 200 Office Supplies Gas Miscellaneous 200 100 250 0 100 250 0 100 250 200 100 250 0 100 250 0 100 250 200 100 250 0 100 250 0 100 250 200 100 250 0 100 250 0 100 250 1 • Click cell B4 to select it. • Type 12000 and then press the RIGHT ARROW Q&A key to enter the data in the selected cell and make the cell to the right (cell C4) the active cell (Figure 1–26). Do I need to enter dollar signs, commas, or trailing zeros for the amounts? You are not required to type dollar signs, commas, or trailing zeros. When you enter a dollar value that has cents, however, you must add the decimal point and the numbers representing the cents. Later in this module, you will learn how to format numbers with dollar signs, commas, and trailing zeros to improve their appearance and readability. cell C4 is active cell 12000 entered in cell B4 Figure 1–26 2 • Refer to Table 1–1 and enter the appropriate values in cells C4, D4, E4, F4, G4, H4, I4, J4, K4, L4, and M4 to complete Q&A the first row of numbers in the worksheet (Figure 1–27). Why are the numbers right-aligned? When you enter numeric data in a cell, Excel recognizes the values as numbers and automatically right-aligns the values in order to vertically align decimal and integer values. commission amounts entered in row 4 numbers rightaligned in cells Figure 1–27 3 • Click cell B5 to select it and complete the entry in the previously selected cell. • Enter the remaining numbers provided in Table 1–1 for each of the nine remaining budget items in row 5 and rows 9–16 (Figure 1–28). data entered in worksheet some row titles only partially visible Figure 1–28 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-19 EX 1-20 Excel Module 1 Creating a Worksheet and a Chart Calculating Sums and Using Formulas The next step in creating the worksheet is to perform any necessary calculations, such as calculating the column and row totals. In Excel, you can easily perform calculations using a function. A function is a special, predefined formula that provides a shortcut for a commonly used calculation, for example, SUM or COUNT. When you use functions, Excel performs the calculations for you, which helps to prevent errors and allows you to work more efficiently. To Sum a Column of Numbers As stated in the requirements document in Figure 1–2, totals are required for each month and each budget item. The first calculation is to determine the total of Commission and Interest income in the month of January (column B). To calculate this value in cell B6, Excel must add, or sum, the numbers in cells B4 and B5. The SUM function adds all the numbers in a range of cells. Why? The Excel SUM function is an efficient means to accomplish this task. Many Excel operations are performed on a range of cells. A range is a series of two or more adjacent cells in a column, row, or rectangular group of cells, notated using the cell address of its upper left and lower right corners, such as B5:C10. For example, the group of adjacent cells B4 and B5 is a range. After calculating the total income for January, you will use the fill handle to calculate the monthly totals for income and expenses and the yearly total for each budget item. The following steps sum the numbers in column B. 1 • Click cell B6 to make it the active cell. • Click the AutoSum button (Home tab | Editing group) to enter a formula in the formula bar and in the active cell Q&A (Figure 1–29). What if my screen displays the Sum menu? If you are using a touch screen, you may not have a separate AutoSum button and AutoSum arrow. In this case, select the desired option (Sum) on the AutoSum menu. How does Excel know which cells to sum? Excel automatically selects what it considers to be your choice of the range to sum. When proposing the range, Excel first looks for a range of cells with numbers above the active cell and then to the left. If Excel proposes the wrong range, you can correct it by dragging through the correct range before pressing ENTER. You also can enter the correct range by typing the beginning cell reference, a colon (:), and the ending cell reference. AutoSum button AutoSum arrow SUM function in formula bar B4:B5 in parentheses indicates range to be summed SUM function displayed in active cell proposed range to sum surrounded by moving border called a marquee Figure 1–29 Editing group 2 Q&A • Click the Enter button in the formula bar to enter the sum in the active cell. What is the purpose of the arrow next to the AutoSum button on the ribbon? The AutoSum arrow (shown in Figure 1–29) displays a list of functions that allow you to easily determine the average of a range of numbers, the number of items in a selected range, or the maximum or minimum value of a range. 3 • Repeat Steps 1 and 2 to enter the SUM function in cell B17 (Figure 1–30). Enter button SUM function entered in cell B6 SUM function entered in cell B17 Figure 1–30 Other Ways 1. Click Insert Function button in formula bar, select SUM in Select a function list, click OK (Insert Function dialog box), click OK (Function Arguments dialog box) 2. Click AutoSum arrow (Home tab | Editing group), click More Functions in list, scroll to and then click SUM (Insert Function dialog box), click OK, select range (Function Arguments dialog box), click OK Using the Fill Handle to Copy a Cell to Adjacent Cells You want to calculate the income totals for each month in cells C6:M6. Table 1–2 illustrates the similarities between the function and range used in cell B6 and the function and ranges required to sum the totals in cells C6, D6, E6, F6, G6, H6, I6, J6, K6, L6, and M6. To calculate each total for each range across the worksheet, you could follow the same steps shown previously in Figure 1–29 and Figure 1–30. A more efficient method, however, would be to copy the SUM function from cell B6 to the range C6:M6. A range of cells you are cutting or copying is called the source area or copy area. The range of cells to which you are pasting is called the destination area or paste area. 3. Type =s in cell, select SUM in list, select range, click Enter button 4. Press ALT+EQUAL SIGN (=) twice Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-21 EX 1-22 Excel Module 1 Creating a Worksheet and a Chart Table 1–2 Sum Function Entries in Row 6 Cell SUM Function Entries Result B6 =SUM(B4:B5) Sums cells B4 and B5 C6 =SUM(C4:C5) Sums cells C4 and C5 D6 =SUM(D4:D5) Sums cells D4 and D5 E6 =SUM(E4:E5) Sums cells E4 and E5 F6 =SUM(F4:F5) Sums cells F4 and F5 G6 =SUM(G4:G5) Sums cells G4 and G5 H6 =SUM(H4:H5) Sums cells H4 and H5 I6 =SUM(I4:I5) Sums cells I4 and I5 J6 =SUM(J4:J5) Sums cells J4 and J5 K6 =SUM(K4:K5) Sums cells K4 and K5 L6 =SUM(L4:L5) Sums cells L4 and L5 M6 =SUM(M4:M5) Sums cells M4 and M5 Although the SUM function entries in Table 1–2 are similar to each other, they are not exact copies. The range in each SUM function entry uses cell references that are one column to the right of the previous column. When you copy and paste a formula that includes a cell reference, Excel uses a relative reference, a cell address that automatically changes to reflect the new location when the formula is copied or moved. You will learn more about relative references in Module 2. Table 1–2 shows how Excel adjusts the SUM functions entries in row 6. Relative referencing is the default type of referencing used in Excel worksheets. To Copy a Cell to Adjacent Cells in a Row The easiest way to copy the SUM formula from cell B6 to cells C6:M6 is to use the fill handle. Why? Using the fill handle copies content to adjacent cells using one action, which is more efficient than other methods. The fill handle is a box that appears in the lower-right corner of a selected cell or range. It is used to fill adjacent cells with duplicate or similar data. The following steps use the fill handle to copy cell B6 to the adjacent cells C6:M6. 1 • With cell B6 active, point to the fill handle; your pointer changes to a crosshair (Figure 1–31). pointer changes to crosshair indicating that you can begin dragging Figure 1–31 2 • Drag the fill handle to select the destination area, the range C6:M6, which will draw a heavy green border around the source area and the destination area (Figure 1–32). Do not release the mouse button. as you drag, Excel displays border around destination and source area source area destination area Figure 1–32 3 • Release the mouse Q&A button to copy the SUM function from the active cell to the destination area and calculate the sums (Figure 1–33). What is the purpose of the Auto Fill Options button? The Auto Fill Options button allows you to choose whether you want to copy the values from the source area to the destination area with the existing formatting, without the formatting, or with the formatting but without the functions. heavy border and transparent gray background indicates B6:M6 remain selected ‘Auto Fill Options’ button remains on screen until you begin next activity SUM function entered in range C6:M6 Figure 1–33 4 • Repeat Steps 1–3 to copy the SUM function from cell B17 to the range C17:M17 (Figure 1–34). SUM function in range C17:M17 Figure 1–34 Other Ways 1. Select source area, click Copy button (Home tab | Clipboard group), select destination area, click Paste button (Home tab | Clipboard group) 2. Right-click source area, click Copy on shortcut menu, select and right-click destination area, click Paste on shortcut menu 3. Select source and destination areas, click Fill arrow (Home tab | Editing group), click Sum Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-23 EX 1-24 Excel Module 1 Creating a Worksheet and a Chart To Calculate Multiple Totals at the Same Time The next step in building the worksheet is to determine the total income, total expenses, and total for each budget item in column N. To calculate these totals, you use the SUM function similarly to how you used it to total the income and expenses for each month in rows 6 and 17. In this case, however, Excel will determine totals for all of the rows at the same time. Why? By determining multiple totals at the same time, the number of steps to add totals is reduced. The following steps sum multiple totals at once. 1 • Click cell N4 to make it the active cell (Figure 1–35). pointer is block plus sign cell N4 is active cell Figure 1–35 2 • With the pointer in cell N4 and in the shape of a block plus sign, drag the pointer down to cell N6 to select the range (Figure 1–36). range N4:N6 selected Figure 1–36 3 Q&A • Click the AutoSum button (Home tab | Editing group) to calculate the sums of all three rows (Figure 1–37). How does Excel create unique totals for each row? If each cell in a selected range is adjacent to a row of numbers, Excel assigns the SUM function to each cell when you click the Sum button. AutoSum button SUM function entered in range N4:N6 Figure 1–37 4 • Repeat Steps 1–3 to select cells N9 to N17 and calculate the sums of the corresponding rows (Figure 1–38). AutoSum button SUM function entered in range N9:N17 Figure 1–38 Calculating Average, Maximum, and Minimum Values As you learned earlier in this module, the AutoSum list lets you calculate not only sums but also the average, the number of items, or the maximum or minimum value of a range. You can calculate these using three additional functions: AVERAGE, MAX, and MIN. The AVERAGE function calculates the average value in a range of cells, the MAX function calculates the maximum value in a range of cells, and the MIN function calculates the minimum value in a range of cells. Table 1–3 shows examples of each of these functions. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-25 EX 1-26 Excel Module 1 Creating a Worksheet and a Chart Table 1–3 AVERAGE, MAX, and MIN Functions Function Result =AVERAGE(H1:H5) Determines the average of the values in cells H1, H2, H3, H4, and H5 =MAX(H1:H5) Determines the maximum value entered in cells H1, H2, H3, H4, and H5 =MIN(H1:H5) Determines the minimum value entered in cells H1, H2, H3, H4, and H5 To Enter a Formula Using the Keyboard The net for each month, which will appear in row 19, is equal to the income total in row 6 minus the expense total in row 17. The formula needed in the worksheet is noted in the requirements document as follows: Net income (row 19) = Total income (row 6) – Total Expenses (row 17) The following steps enter the net income formula in cell B19 using the keyboard. Why? Sometimes a predefined function does not fit your needs; therefore, you enter a formula of your own. 1 • Select cell B19 to deselect the selected range. • Type =b6-b17 in the cell. The formula is displayed in the formula bar and the current cell, and colored borders Q&A are drawn around the cells referenced in the formula (Figure 1–39). What occurs on the worksheet as I enter the formula? The equal sign (=) preceding b6–b17 in the formula alerts Excel that you are entering a formula or function and not text. Because the most common error when entering a formula is to reference the wrong cell, Excel highlights the cell references in the formula in color and uses the same colors to highlight the borders of the cells to help ensure that your cell references are correct. The minus sign (–) following b6 in the formula is the arithmetic operator that directs Excel to perform the subtraction operation. formula displayed in formula bar formula entered in B19 (green outline), which will display B6 (blue highlight) minus B17 (red highlight) Figure 1–39 2 • Click cell C19 to complete the arithmetic operation, display the result in the worksheet, and select the cell to the right (Figure 1–40). cell C19 selected sum displayed Figure 1–40 To Copy a Cell to Adjacent Cells in a Row Using the Fill Handle The easiest way to copy the SUM formula from cell B19 to cells C19, D19, E19, F19, G19, H19, I19, J19, K19, L19, M19, and N19 is to use the fill handle. The following steps use the fill handle to copy the formula in cell B19 to the adjacent cells C19:N19. 1 Select cell B19. 2 Drag the fill handle to select the destination area, range C19:N19, which highlights and draws a border around the source area and the destination area. Release the mouse button to copy the function from the active cell to the destination area and calculate the results. Saving the Project While you are building a worksheet in a workbook, the computer stores it in memory. When you save a workbook, the computer places it on a storage medium such as a hard drive, USB flash drive, or online using a service such as OneDrive. A saved workbook is called a file. A file name is the name assigned to a file when you save it. It is important to save the workbook frequently for the following reasons: • The worksheet in memory will be lost if the computer is turned off or you lose electrical power while Excel is open. BTW Organizing Files and Folders You should organize and store files in folders so that you can easily find the files later. For example, if you are taking an introductory technology class called CIS 101, a good practice would be to save all Excel files in an Excel folder in a CIS 101 folder. Where should you save the workbook? When saving a workbook, you must decide which storage medium to use: • If you always work on the same computer and have no need to transport your projects to a different location, then your computer’s hard drive will suffice as a storage location. It is a good idea, however, to save a backup copy of your projects on a separate medium, such as an external drive, in case the file becomes corrupted or the computer’s hard drive fails. The workbooks used in this book are saved to the computer’s hard drive. • If you plan to work on your workbooks in various locations or on multiple computers or mobile devices, then you should save your workbooks on a portable medium, such as a USB flash drive. Alternatively, you can save your workbooks to an online cloud storage service such as OneDrive. CONSIDER THIS • If you run out of time before completing your workbook, you may finish your worksheet at a future time without starting over. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-27 EX 1-28 Excel Module 1 Creating a Worksheet and a Chart To Save a Workbook The following steps save a workbook in the Documents library on the hard drive using the file name, Frangold Real Estate Budget. Why? You have performed many tasks while creating this project and do not want to risk losing the work completed thus far. 1 • Click File on the ribbon to open Backstage view (Figure 1–41). Back button Info screen Backstage view Info tab selected Figure 1–41 2 • Click Save As in Backstage view to display the Save As screen (Figure 1–42). Save As screen recent save locations Save As available save locations Figure 1–42 3 • Click This PC in the Other locations section to display the default save location on the computer or mobile device (Figure 1–43). More options link This PC selected Figure 1–43 4 New folder button • Click the More options link to display the Save As dialog box. • If necessary, click Documents in Save As dialog box file will be saved in Documents library the Navigation pane to select the Documents library as the save location. • Type Frangold Real Q&A Estate Budget in the File name text box to specify the file name for the workbook (Figure 1–44). Do I have to save to the Documents library? No. You can save to any device or folder. A folder is a specific location on a storage medium. You can save to the default folder or a different folder. You also can create your own folders by clicking the New folder button shown in Figure 1–44. To save to a different location, navigate to that location in the Navigation pane instead of clicking Documents. file name entered in File name text box Save button Figure 1–44 What characters can I use in a file name? The only invalid characters are the backslash (\), slash (/), colon (:), asterisk (*), question mark (?), quotation mark (“), less than symbol (<), greater than symbol (>), and vertical bar (|). Why is my list of files, folders, and drives arranged and named differently from those shown in the figure? Your computer or mobile device’s configuration determines how the list of files and folders is displayed and how drives are named. You can change the save location by clicking links in the Navigation pane. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-29 EX 1-30 Excel Module 1 Creating a Worksheet and a Chart 5 • Click the Save button to save the workbook with the file name Frangold Real Estate Budget to the default save Q&A location (Figure 1–45). How do I know that Excel saved the workbook? While Excel is saving your file, it briefly displays a message on the status bar indicating the amount of the file saved. When the workbook appears after saving, the new file name and the word, Saved, appear in the title bar. Why is the AutoSave button disabled on the title bar? If you are saving the file to a computer or mobile device, the AutoSave button on the title bar may be disabled (dimmed). If you are saving the file to OneDrive, the AutoSave button may be enabled, allowing you to specify whether Excel saves the workbook as you make changes to it. If AutoSave is turned off, you will need to continue saving your changes manually. new file name appears in title bar results of formula display in row 19 Figure 1–45 Other Ways 1. Press F12, type file name (Save As dialog box), navigated to desired save location, click Save button Break Point: If you want to take a break, this is a good place to do so. You can exit Excel now. To resume later, start Excel, open the file called Frangold Real Estate Budget, and continue following the steps from this location forward. Formatting the Worksheet The text, numeric entries, and functions for the worksheet now are complete. The next step is to format the worksheet. You format a worksheet to enhance the appearance of information by changing its font, size, color, or alignment. Figure 1–46a shows the worksheet before formatting. Figure 1–46b shows the worksheet after formatting. As you can see from the two figures, a worksheet that is formatted not only is easier to read but also looks more professional. • Identify in what ways you want to emphasize various elements of the worksheet. • Increase the font size of cells. • Change the font color of cells. • Center the worksheet titles, subtitles, and column headings. • Modify column widths to best fit text in cells. • Change the font style of cells. (a) Unformatted Worksheet (b) Formatted Worksheet Figure 1–46 Excel Module 1 What steps should you consider when formatting a worksheet? The key to formatting a worksheet is to consider the ways you can enhance the worksheet so that it appears professional. When formatting a worksheet, consider the following steps: CONSIDER THIS Creating a Worksheet and a Chart Excel Module 1 EX 1-31 EX 1-32 Excel Module 1 Creating a Worksheet and a Chart To change the unformatted worksheet in Figure 1–46a so that it looks like the formatted worksheet in Figure 1–46b, the following tasks must be completed: 1. Change the font, change the font style, increase the font size, and change the font color of the worksheet titles in cells A1 and A2. 2. Center the worksheet titles in cells A1 and A2 across columns A through N. 3. Format the body of the worksheet. The body of the worksheet, range A3:N19, includes the column titles, row titles, and numbers. Formatting the body of the worksheet changes the numbers to use a dollars-and-cents format, with dollar signs in rows 4 and 9 and in the total rows (row 6 and 17); changes the styles of some rows; adds underlining that emphasizes portions of the worksheet; and modifies the column widths to fit the text in the columns and make the text and numbers readable. Although the formatting procedures are explained in the order described above, you could make these format changes in any order. Modifying the column widths, however, is usually done last because other formatting changes may affect the size of data in the cells in the column. Font Style, Size, and Color The characters that Excel displays on the screen are a specific font, style, size, and color. The font defines the appearance and shape of the letters, numbers, and special characters. Examples of fonts include Calibri, Cambria, Times New Roman, Arial, and Courier. A font style is a format that indicates how characters are emphasized, such as bold, underline, and italic. The font size refers to the size of characters, measured in units called points. A point is a unit of measure used for font size and, in Excel, row height; one point is equal to 1/72 of an inch. Thus, a character with a point size of 10 is 10/72 of an inch in height. Finally, Excel has a wide variety of font colors. Font color refers to the color of the characters in a spreadsheet. When Excel first starts, the default font for the entire workbook is Calibri, with a font size, font style, and font color of 11-point regular black. You can change the font characteristics in a single cell, a range of cells, the entire worksheet, or the entire workbook. To Change a Cell Style You can change several characteristics of a cell, such as the font, font size, and font color, all at once by assigning a predefined cell style to a cell. A cell style is a predesigned combination of font, font size, and font color that you can apply to a cell. Why? Using the predesigned styles provides a consistent appearance to common portions of your worksheets, such as worksheet titles, worksheet subtitles, column headings, and total rows. The following steps assign the Title cell style to the worksheet title in cell A1. 1 • Click cell A1 to make cell A1 the active cell. • Click the Cell Styles button (Home tab | Styles group) to display the Cell Styles gallery (Figure 1–47). Cell Styles button cell A1 selected Cell Styles gallery Figure 1–47 2 • Point to the Title cell style in the Titles and Headings area of the Cell Styles gallery to see a live preview of the cell style in the active cell (Figure 1–48). Experiment • If you are using a mouse, point to other cell styles in the Cell Styles gallery to see a live preview of those cell styles in cell A1. Title and Headings area live preview of Title cell style in cell A1 Figure 1–48 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-33 EX 1-34 Excel Module 1 Creating a Worksheet and a Chart 3 • Click the Title cell Q&A style to apply the cell style to the active cell (Figure 1–49). Why do settings in the Font group on the ribbon change? The font and font size change to reflect the font changes applied to the active cell, cell A1, as a result of applying the Title cell style. cell A1 formatted using Title cell style Figure 1–49 To Change the Font Why? Different fonts are often used in a worksheet to make it more appealing to the reader and to relate or distinguish data in the worksheet. The following steps change the worksheet subtitle’s font to Arial Narrow. 1 • Click cell A2 to make Font arrow it the active cell. • Click the Font arrow (Home tab | Font group) to display the Font gallery. If necessary, scroll to Arial Narrow. • Point to Arial Narrow in the Font gallery to see a live preview of the selected font in the active cell (Figure 1–50). Experiment • If you are using a mouse, point to several other fonts in the Font gallery to see a live preview of the other fonts in the selected cell. Font gallery live preview of Arial Narrow font in cell A2 Arial Narrow font Figure 1–50 2 • Click Arial Narrow in the Font gallery to change the font of the worksheet subtitle to Arial Narrow (Figure 1–51). Arial Narrow font applied to cell A2 Figure 1–51 Other Ways 1. Click Font Settings Dialog Box Launcher, click Font tab (Format Cells dialog box), click desired color in Color list, click OK 2. Right-click the cell to display Mini toolbar, click Font Color arrow on Mini toolbar, click desired font color in Font Color gallery 3. Right-click selected cell, click Format Cells on shortcut menu, click Font tab (Format Cells dialog box), click desired color in Color list, click OK To Apply Bold Style to a Cell Bold, or boldface, text has a darker appearance than normal text. Why? You apply bold style to a cell to emphasize it or make it stand out from the rest of the worksheet. The following steps apply bold style to the worksheet title and subtitle. 1 • Click cell A1 to make it active and then click Q&A the Bold button (Home tab | Font group) to change the font style of the active cell to bold (Figure 1–52). Bold button What if a cell already has the bold style applied? If the active cell contains bold text, then Excel displays the Bold button with a darker gray background. How do I remove the bold style from a cell? Clicking the Bold button (Home tab | Font group) a second time removes the bold style. 2 • Repeat Step 1 to bold cell A2. bold applied to cell A1 Figure 1–52 Other Ways 1. Click Font Settings Dialog Box Launcher, click Font tab (Format Cells dialog box), click Bold in Font style list, click OK 3. Right-click selected cell, click Format Cells on shortcut menu, click Font tab (Format Cells dialog box), click Bold in Font style list, click OK 2. Right-click selected cell, click Bold button on Mini toolbar 4. Press CTRL+B Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-35 EX 1-36 Excel Module 1 Creating a Worksheet and a Chart To Increase the Font Size of a Cell Entry Increasing the font size is the next step in formatting the worksheet subtitle. Why? You increase the font size of a cell so that the entry stands out and is easier to read. The following steps increase the font size of the worksheet subtitle in cell A2. 1 Font Size arrow • With cell A2 selected, click the Font Size arrow (Home tab | Font group) to display the Font Size gallery. • Point to 16 in the Font Size gallery to see a live preview of the active cell with the selected font size (Figure 1–53). Font Size gallery Experiment • If you are using a mouse, point to several other font sizes in the Font Size list to see a live preview of those font sizes in the selected cell. font size 16 bold applied to cell A2 Figure 1–53 2 • Click 16 in the Font Size gallery Q&A to change the font size in the active cell (Figure 1–54). Can I choose a font size that is not in the Font Size gallery? Yes. To select a font size not displayed in the Font Size gallery, such as 13, click the Font Size box (Home tab | Font group), type the font size you want, and then press ENTER. font size changed Figure 1–54 Other Ways 1. Click ‘Increase Font Size’ button (Home tab | Font group) or ‘Decrease Font Size’ button (Home tab | Font group) 2. Click Font Settings Dialog Box Launcher, click Font tab (Format Cells dialog box), click desired size in Size list, click OK 3. Right-click cell to display Mini toolbar, click Font Size arrow on Mini toolbar, click desired font size in Font Size gallery 4. Right-click selected cell, click Format Cells on shortcut menu, click Font tab (Format Cells dialog box), select font size in Size box, click OK To Change the Font Color of a Cell Entry The next step is to change the color of the font in cells A1 and A2 to green. Why? Changing the font color of cell entries can help the text stand out more. You also can change the font colors to match a company’s or product’s brand colors. The following steps change the font color of a cell entry. 1 • Click cell A1 and then click the Font Color arrow (Home tab | Font group) to display the Font Color gallery. Font Color arrow • If you are using a mouse, point to Green, Accent 6 (column 10, row 1) in the Theme Colors area of the Font Color gallery to see a live preview of the font color in the active cell (Figure 1–55). Font Color gallery live preview of color Experiment ‘Green, Accent 6’ • Point to several other colors in Q&A the Font Color gallery to see a live preview of other font colors in the active cell. How many colors are in the Font Color gallery? Figure 1–55 You can choose from approximately 70 different font colors in the Font Color gallery. Your Font Color gallery may have more or fewer colors, depending on the color settings of your operating system. The Theme Colors area contains colors that are included in the current workbook’s theme. 2 • Click Green, Accent 6 (column 10, row 1) in the Font Color gallery to Q&A change the font color of the worksheet title in the active cell (Figure 1–56). Why does the Font Color button change after I select the new font color? When you choose a color on the Font Color gallery, Excel changes the Font Color button (Home tab | Font group) to your chosen color. Then when you want to change the font color of another cell to the same color, you need only to select the cell and then click the Font Color button (Home tab | Font group). font color changed 3 Figure 1–56 • Click cell A2. • Click the Font Color button to apply Green, Accent 6 (column 10, row 1) to cell A2. Other Ways 1. Click Font Settings Dialog Box Launcher, click Font tab (Format Cells dialog box), click desired font color in Color list, click OK 2. Right-click cell to display Mini toolbar, click Font Color arrow on Mini toolbar, click desired color in Font Color gallery 3. Right-click selected cell, click Format Cells on shortcut menu, click Font tab (Format Cells dialog box), click Color arrow, click desired color, click OK Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-37 EX 1-38 Excel Module 1 Creating a Worksheet and a Chart To Center Cell Entries across Columns by Merging Cells The final step in formatting the worksheet title and subtitle is to center them across columns A through N. Why? Centering a title across the columns used in the body of the worksheet improves the worksheet’s appearance. To do this, the 14 cells in the range A1:N1 are combined, or merged, into a single cell that is the width of the columns in the body of the worksheet. The 14 cells in the range A2:N2 are merged in a similar manner. When you merge cells, you combine multiple adjacent cells into one larger cell. To unmerge cells, you split them to display the original range of cells. The following steps center the worksheet title and subtitle across columns by merging cells. 1 Q&A • Select cell A1 and then drag to cell N1 to highlight the range to be merged and centered (Figure 1–57). What if a cell in the range B1:N1 contains data? For the ‘Merge & Center’ button (Home tab | Alignment group) to work properly, all the cells except the leftmost cell in the selected range must be empty. range A1:N1 selected for merging Figure 1–57 2 • Click the ‘Merge & Center’ button (Home tab | Alignment group) to merge cells A1 through N1 and center the Q&A contents of the leftmost cell across the selected columns (Figure 1–58). What if my screen displays a Merge & Center menu? If you are using a touch screen, Excel might display a Merge & Center menu. Select the desired option on the Merge & Center menu if you do not have a separate ‘Merge & Center’ button and ‘Merge & Center’ arrow. What happened to cells B1 through N1? After the merge, cells B1 through N1 no longer exist. The new cell A1 now extends across columns A through N. ‘Merge & Center’ button cell range merged and text centered in one cell (A1) Figure 1–58 3 • Repeat Steps 1 and 2 Q&A to merge and center the worksheet subtitle across cells A2 through N2 (Figure 1–59). cells merged and centered Are cells B1 through N1 and B2 through N2 lost forever? No. You can split a merged cell to Figure 1–59 redisplay the individual cells. You split a merged cell by selecting it and clicking the ‘Merge & Center’ button. For example, if you click the ‘Merge & Center’ button a second time in Step 2, it will split the merged cell A1 into cells A1, B1, C1, D1, E1, F1, G1, H1, I1, J1, K1, L1, M1, and N1, and move the title to its original location in cell A1. Other Ways 1. Right-click selection, click ‘Merge & Center’ button on Mini toolbar 2. Right-click selected cell, click Format Cells on shortcut menu, click Alignment tab (Format Cells dialog box), select ‘Center Across Selection’ in Horizontal list, click OK To Format Rows Using Cell Styles The next step to format the worksheet is to format the rows. Why? Row titles and the total row should be formatted so that the column titles and total row can be distinguished from the data in the body of the worksheet. Data rows can be formatted to make them easier to read as well. The following steps format the column titles and total row using cell styles in the default worksheet theme. 1 • Click cell A3 and then drag to cell N3 to select the range. • Click the Cell Styles button (Home tab | Styles group) to display the Cell Styles gallery. • Point to the Heading 1 cell style in the Titles and Headings area of the Cell Styles gallery to see a live preview of the cell style in the selected range (Figure 1–60). Experiment • If you are using a mouse, point to other cell styles in the Titles and Headings area of the Cell Styles gallery to see a live preview of other styles. Cell Styles button Cell Styles gallery live preview of cell style Heading 1 cell style Figure 1–60 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-39 EX 1-40 Excel Module 1 Creating a Worksheet and a Chart 2 • Click the Heading 1 Center button cell style to apply the cell style to the selected range. • Click the Center button (Home tab | Alignment group) to center the column headings in the selected range. Heading 1 style applied and column heading centered • Select the range A8 to N8 (Figure 1–61). 3 range A8:N8 Figure 1–61 • Apply the Heading 1 cell style format and then center the headings (Figure 1–62). Heading 1 style applied and column headings centered 4 Figure 1–62 • Format the ranges A6:N6 and A17:N17 with the Total cell style format. • Format the range A19:N19 with the Accent6 cell style format. • Format the ranges A4:N4, A9:N9, A11:N11, A13:N13, A15:N15 with the 20% - Accent6 cell style format. styles applied to all rows • Format the range A5:N5, A10:N10, A12:N12, A14:N14, A16:N16 with the 40% - Accent6 cell style format. Deselect the selected ranges (Figure 1–63). Figure 1–63 To Format Numbers in the Worksheet The requirements document requested that numbers in the first row and last row of each section should be formatted to use a dollar-and-cents format, while other numbers receive a comma format. Why? Using a dollar-and-cents format for selected cells makes it clear to users of the worksheet that the numbers represent dollar values without cluttering the entire worksheet with dollar signs, and applying the comma format makes larger numbers easier to read. Excel allows you to apply various number formats, many of which are discussed in later modules. The following steps use buttons on the ribbon to format the numbers in the worksheet. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-41 1 • Select the range B4:N4. • Click the ‘Accounting Number Format’ button (Home tab | Number group) to apply the accounting number format to the cells in the selected range. ‘Accounting Number Format’ button accounting number format applied to range B4:N4 range B5:N5 selected • Select the range Q&A B5:N5 (Figure 1–64). Figure 1–64 What if my screen displays an Accounting Number Format menu? If you are using a touch screen, you may not have a separate ‘Accounting Number Format’ button and ‘Accounting Number Format’ arrow. In this case, select the desired option on the Accounting Number Format menu. What effect does the accounting number format have on the selected cells? The accounting number format causes numbers to be displayed with two decimal places and to align vertically. Cell widths are adjusted automatically to accommodate the new formatting. 2 Q&A • Click the Comma Style button (Home tab | Number group) to apply the comma style format to the selected range. What effect does the comma style format have on the selected cells? The comma style format formats numbers to have two decimal places and commas as thousands separators. • Select the range B6:N6 to make it the active range (Figure 1–65). Comma Style button comma style format applied to range B5:N5 Figure 1–65 range B6:N6 selected EX 1-42 Excel Module 1 Creating a Worksheet and a Chart 3 • Click the ‘Accounting Number Format’ button (Home tab | Number group) to apply the accounting number format to the cells in the selected range. 4 • Format the ranges B9:N9, B17:N17, and B19:N19 with the accounting number format. Q&A • Format the range B10:N16 with the comma style format. Click cell A1 to deselect the selected ranges (Figure 1–66). How do I select the range B10:N16? Select this range the same way as you select a range of cells in a column or row; that is, click the first cell in the range (B10, in this case) and drag to the last cell in the range (N16, in this case). accounting number format applied formats applied to remaining rows Figure 1–66 Other Ways 1. Click ‘Accounting Number Format’ or Comma Style button on Mini toolbar 2. Right-click selected cell, click Format Cells on shortcut menu, click Number tab (Format Cells dialog box), select Accounting in Category list or select Number and click ‘Use 1000 Separator’, click OK To Adjust the Column Width The last step in formatting the worksheet is to adjust the width of the columns so that each title is visible. Why? To make a worksheet easy to read, the column widths should be adjusted appropriately. Excel offers other methods for adjusting cell widths and row heights, which are discussed later in this book. The following steps adjust the width of columns A through N so that the contents of the columns are visible. 1 • Point to the boundary on the right side of the column A heading above row 1 to change the pointer to a split double arrow (Figure 1–67). pointer changes to split double arrow Figure 1–67 2 • Double-click the boundary to Q&A adjust the width of the column to accommodate the width of the longest item in the column (Figure 1–68). What if all of the items in the column are already visible? If all of the items are shorter in length than the width of the column and you double-click the column boundary, Excel will reduce the width of the column to the width of the widest entry. column A resized cell contents visible Figure 1–68 3 • Repeat Steps 1 and 2 to adjust the column width of columns B through N (Figure 1–69). columns B through N resized Figure 1–69 Other Ways 1. Select column heading, click Format (Home tab | Cells group), click AutoFit Column Width Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-43 EX 1-44 Excel Module 1 Creating a Worksheet and a Chart To Use the Name Box to Select a Cell The next step is to chart the monthly expenses. To create the chart, you need to identify the range of the data you want to feature on the chart and then select it. In this case you want to start with cell A3. Rather than clicking cell A3 to select it, you will select the cell by using the Name box, which is located to the left of the formula bar. Why? You might want to use the Name box to select a cell if you are working with a large worksheet and it is faster to type the cell name rather than scrolling to and clicking it. The following steps select cell A3 using the Name box. 1 • Click the Name box in the formula bar and then type a3 as the cell you want to select (Figure 1–70). a3 entered in Name box Figure 1–70 2 • Press ENTER to change the active cell in the Name box and make cell A3 the active cell (Figure 1–71). cell A3 is active cell Figure 1–71 Other Ways to Select Cells As you will see in later modules, in addition to using the Name box to select any cell in a worksheet, you also can use it to assign names to a cell or range of cells. Excel supports several additional ways to select a cell, as summarized in Table 1–4. Table 1–4 Selecting Cells in Excel Key, Box, or Command Function alt+page down Selects the cell one worksheet window to the right and moves the worksheet window accordingly. alt+page up Selects the cell one worksheet window to the left and moves the worksheet window accordingly. arrow Selects the adjacent cell in the direction of the arrow on the key. ctrl+arrow Selects the border cell of the worksheet in combination with the arrow keys and moves the worksheet window accordingly. For example, to select the rightmost cell in the row that contains the active cell, press ctrl+right arrow. You also can press end, release it, and then press the appropriate arrow key to accomplish the same task. ctrl+home Selects cell A1 or the cell one column and one row below and to the right of frozen titles and moves the worksheet window accordingly. Find command on Find & Select menu (Home tab | Editing group) or shift+f5 Finds and selects a cell that contains specific contents that you enter in the Find and Replace dialog box. If necessary, Excel moves the worksheet window to display the cell. You also can press ctrl+f to display the Find and Replace dialog box. Go To command on Find & Select menu (Home tab | Editing group) or f5 Selects the cell that corresponds to the cell reference you enter in the Go To dialog box and moves the worksheet window accordingly. You also can press ctrl+g to display the Go To dialog box and its Special button to go to special worksheet elements, such as formulas. home Selects the cell at the beginning of the row that contains the active cell and moves the worksheet window accordingly. Name box Selects the cell in the workbook that corresponds to the cell reference you enter in the Name box. page down Selects the cell down one worksheet window from the active cell and moves the worksheet window accordingly. page up Selects the cell up one worksheet window from the active cell and moves the worksheet window accordingly. Break Point: If you want to take a break, this is a good place to do so. Be sure to save the Frangold Real Estate Budget file again, and then you can exit Excel. To resume later start Excel, open the file called Frangold Real Estate Budget, and continue following the steps from this location forward. Adding a Pie Chart to the Worksheet Excel includes 17 chart types from which you can choose, including column, line, pie, bar, area, X Y (scatter), map, stock, surface, radar, treemap, sunburst, histogram, box & whisker, waterfall, funnel, and combo. The type of chart you choose depends on the type and quantity of data you have and the message or analysis you want to convey. A column chart is a good way to compare values side by side. A line chart is often used to illustrate changes in data over time. Pie charts show the contribution of each piece of data to the whole, or total, of the data. A pie chart can go even further in comparing values across categories by showing each pie piece in comparison with the others. Area charts, like line charts, illustrate changes over time but are often used to compare more than one set of data, and the area below the lines is filled in with a different color for each set of data. An X Y (scatter) chart is used much like a line chart, but each piece of data is represented by a dot and is not connected with a line. Scatter charts are typically used for viewing scientific, statistical, and engineering data. A map chart depicts data based on geographic location. A stock chart provides a number of methods commonly used in the financial industry to show fluctuations in stock market data. A surface chart compares data from three columns and/or rows in a 3-D manner. A radar chart can compare aggregate values of several sets of data in a manner that resembles a radar screen, with each set of data represented by a different color. A funnel chart illustrates values during various stages. A combo chart allows you to combine multiple types of charts. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-45 EX 1-46 Excel Module 1 Creating a Worksheet and a Chart As outlined in the requirements document in Figure 1–2, the budget worksheet should include a pie chart to graphically represent the yearly expense totals for each item in Frangold Real Estate’s budget. The pie chart shown in Figure 1–72 is on its own sheet in the workbook. The pie chart resides on a separate sheet, called a chart sheet. A chart sheet is a separate sheet in a workbook that contains only a chart, which is linked to the workbook data. chart title pie chart chart legend chart sheet Figure 1–72 In this worksheet, the ranges you want to chart are the nonadjacent ranges A9:A16 (expense titles) and N9:N16 (yearly expense totals). The expense titles in the range A9:A16 will identify the slices of the pie chart; these entries are called category names. The range N9:N16 contains the data that determine the size of the slices in the pie; these entries are called the data series. A data series is a column or row in a datasheet and also the set of values represented in a chart. Because eight budget items are being charted, the pie chart contains eight slices. To Add a Pie Chart Why? When you want to see how each part relates to the whole, you use a pie chart. The following steps draw the pie chart. 1 • Select the range A9:A16 to identify the range of the category names for the pie chart. • While holding down CTRL, select the nonadjacent range N9:N16. • Click Insert on the ribbon to display the Insert tab. • Click the ‘Insert Pie or Doughnut Chart’ button (Insert tab | Charts group) to display the Insert Pie or Doughnut Chart gallery (Figure 1–73). Insert tab ‘Insert Pie or Doughnut Chart’ button Pie ‘Insert Pie or Doughnut Chart’ gallery ranges A9:A16 and N9:N16 selected Figure 1–73 2 • Click Pie in the 2-D Q&A category of the Insert Pie or Doughnut Chart gallery to insert the chart in the worksheet (Figure 1–74). Why have new tabs appeared on the ribbon? The new tabs provide additional options and functionality when you are working with certain objects, such as charts, and only display when you are working with those objects. pie chart created Figure 1–74 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-47 EX 1-48 Excel Module 1 Creating a Worksheet and a Chart 3 • Click the chart title to select it. • Click and drag to chart title select all the text in the chart title. • Type Monthly Expenses to specify the title. • Click a blank area of the chart to deselect the chart title (Figure 1–75). Figure 1–75 To Apply a Style to a Chart Why? If you want to enhance the appearance of a chart, you can apply a chart style. The following steps apply Style 6 to the pie chart. 1 • Click the Chart Styles button to the right of the chart to display the Chart Styles gallery. • Scroll in the Chart Styles gallery to display the Style 6 chart style (Figure 1–76). Chart Styles button Chart Styles gallery scroll box Chart Style 6 Figure 1–76 2 • Click Style 6 in the Chart Styles gallery to change the chart style to Style 6 (Figure 1–77). 3 • Click the Chart Styles button to close the Chart Styles gallery. Style 6 selected Figure 1– 77 Changing the Sheet Tab Names and Colors The sheet tabs at the bottom of the window allow you to navigate between any worksheet in the workbook. You click the sheet tab of the worksheet you want to view in the Excel window. By default, the worksheets are named Sheet1, Sheet2, and so on. The worksheet names become increasingly important as you move toward more sophisticated workbooks, especially workbooks in which you place objects such as charts on different sheets, which you will do in the next section, or you reference cells between worksheets. BTW Exploding a Pie Chart If you want to draw attention to a particular slice in a pie chart, you can offset the slice so that it stands out from the rest. A pie chart with one or more slices offset is referred to as an exploded pie chart. To offset a slice, click the slice two times to select it (do not double-click) and then drag the slice outward. To Move a Chart to a New Sheet Why? By moving a chart to its own sheet, the size of the chart will increase, which can improve readability. The following steps move the pie chart to a chart sheet named Monthly Expenses. 1 Move Chart dialog box • Click the Move Chart button (Chart Tools Design tab | Location group) to display the Move Chart dialog box (Figure 1–78). Move Chart button New sheet text box OK button Figure 1–78 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-49 EX 1-50 Excel Module 1 Creating a Worksheet and a Chart 2 • Click New sheet to select it (Move Chart dialog box) and then type Monthly Expense Chart in the New sheet text box to enter a sheet tab name for the worksheet that will contain the chart. • Click OK (Move Chart dialog box) to move the chart to a new chart sheet with the sheet tab name, Monthly Expense Chart (Figure 1–79). chart moved to Monthly Expense Chart sheet Sheet1 tab Figure 1–79 To Change the Sheet Tab Name and Color You decide to change the name and color of the Sheet1 tab to Monthly Finances. Why? Use simple, meaningful names for each sheet tab. Sheet tab names often match the worksheet title. If a worksheet includes multiple titles in multiple sections of the worksheet, use a sheet tab name that encompasses the meaning of all of the sections. Changing the tab color also can help uniquely identify a sheet. The following steps rename the sheet tab and change the tab color. 1 • Double-click the sheet tab labeled Sheet1 in the lower-left corner of the window. • Type Monthly Finances as the sheet tab Q&A name and then press ENTER to assign the new name to the sheet tab (Figure 1–80). sheet tab name changed What is the maximum length for a sheet tab name? Sheet tab names can be up to 31 characters Figure 1–80 (including spaces) in length. Longer worksheet names, however, mean that fewer sheet tabs will appear on your screen. If you have multiple worksheets with long sheet tab names, you may have to scroll through sheet tabs, making it more difficult to find a particular sheet. 2 shortcut menu • Right-click the sheet tab labeled Monthly Finances, in the lowerleft corner of the window, to display a shortcut menu. Green, Accent 6 • Point to Tab Color on the shortcut menu to display the Tab Color gallery (Figure 1–81). Tab Color command Tab Color gallery Figure 1–81 3 Home tab • Click Green, Accent 6 (column 10, row 1) in the Theme Colors area to change the color of the tab (Figure 1–82). • If necessary, click Home on the ribbon to display the Home tab. • Click the Save button on the Q&A Quick Access Toolbar to save the workbook again on the same storage location with the same file name. Why should I save the workbook again? You have made several modifications to the workbook since you last saved it. Thus, you should save it again. What if I want to change the file name or storage location when I save the workbook? Click Save As in Backstage view and follow the “To Save a Workbook” steps earlier in this module to specify a different file name and/or storage location. tab color changed to Green, Accent 6 Figure 1–82 Document Properties Excel helps you organize and identify your files by using document properties, which are the details about a file such as the project author, title, and subject. For example, you could use the class name or topic to describe the workbook’s purpose or content in the document properties. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-51 Why would you want to assign document properties to a workbook? Document properties are valuable for a variety of reasons: • Users can save time locating a particular file because they can view a file’s document properties without opening the workbook. • By creating consistent properties for files having similar content, users can better organize their workbooks. • Some organizations require Excel users to add document properties so that other employees can view details about these files. Common document properties include standard properties and those that are automatically updated. Standard properties are document properties associated with all Microsoft Office files and include author, title, and subject. Automatically updated properties are file system or document properties, such as the date you create or change a file, and statistics, such as the file size. TO CHANGE DOCUMENT PROPERTIES To change document properties, you would follow these steps. 1. Click File on the ribbon to open Backstage view and then, if necessary, click the Info tab in Backstage view to display the Info screen. The Properties list is located in the right pane of the Info screen. 2. If the property you want to change is in the Properties list, click to the right of the property category to display a text box. (Note that not all properties are editable.) Type the desired text for the property and then click anywhere in the Info screen to enter the data or press TAB to navigate to the next property. Click the Back button in the upper-left corner of Backstage view to return to the Excel window. 3. If the property you want to change is not in the Properties list or you cannot edit it, click the Properties button to display the Properties menu, and then click Advanced Properties to display the Summary tab in the Properties dialog box. Type your desired text in the appropriate property text boxes. Click OK (Properties dialog box) to close the dialog box and then click the Back button in the upper-left corner of Backstage view to return to the workbook. Q&A CONSIDER THIS EX 1-52 Excel Module 1 Creating a Worksheet and a Chart Why do some of the document properties in my Properties dialog box contain data? Depending on where you are using Excel, your school, university, or place of employment may have customized the properties. Printing a Worksheet After creating a worksheet, you may want to preview and print it. A preview is an onscreen view of your document prior to printing, to see exactly how the printed document will look. Printing a worksheet enables you to distribute the worksheet to others in a form that can be read or viewed but not edited. It is a good practice to save a workbook before printing a worksheet, in the event you experience difficulties printing. • Some people prefer proofreading a hard copy of a workbook rather than viewing it on the screen to check for errors and readability. • Hard copies can serve as a backup reference if your storage medium is lost or becomes corrupted and you need to recreate the workbook. Instead of distributing a hard copy of a workbook, users can distribute the workbook as an electronic image that mirrors the original workbook’s appearance. An electronic image of a workbook is not an editable file; it simply displays a picture of the workbook. The electronic image of the workbook can be sent as an email attachment, posted on a website, or copied to a portable storage medium such as a USB flash drive. Two popular electronic image formats, sometimes called fixed formats, are PDF by Adobe Systems and XPS by Microsoft. In Excel, you can create electronic image files through the Save As dialog box and the Export, Share, and Print tabs in Backstage view. Electronic images of workbooks, such as PDF and XPS, can be useful for the following reasons: • Users can view electronic images of workbooks without the software that created the original workbook (e.g., Excel). Specifically, to view a PDF file, you use a program called Adobe Reader, which can be downloaded free from the Adobe website. Similarly, to view an XPS file, you use a program called XPS Viewer, which is included in the latest version of Windows. • Sending electronic workbooks saves paper and printer supplies. Society encourages users to contribute to green computing, which involves reducing the electricity consumed and environmental waste generated when using computers, mobile devices, and related technologies. To Preview and Print a Worksheet in Landscape Orientation With the completed workbook saved, you may want to print it. Why? A printed copy is sometimes necessary for a report delivered in person. An on-screen preview of your worksheet lets you see each page of your worksheet in the current orientation. Portrait orientation describes a printed copy with the short (8½") edge at the top of the printout; the printed page is taller than it is wide. Landscape orientation describes the page orientation in which the page is wider than it is tall. The print settings allow you to change the orientation as well as the paper size, margins, and scaling. Scaling determines how the worksheet fits on the page. You may want to adjust scaling to ensure that your data fits on one sheet of paper. Why? A printed worksheet may be difficult to read if it is spread across more than one page. The following steps print one or more hard copies of the contents of the worksheet. 1 • Click File on the ribbon to open Backstage view. Q&A • Click Print in Backstage view to display the Print screen (Figure 1–83). How can I print multiple copies of my worksheet? Increase the number in the Copies box on the Print screen. What if I decide not to print the worksheet at this time? Click the Back button in the upper-left corner of Backstage view to return to the workbook window. Why does my Print screen look different? Depending on the type of printer you select, your Print screen may display different options. Excel Module 1 What is the best method for distributing a workbook? The traditional method of distributing a workbook uses a printer to produce a hard copy. A hard copy or printout is information that exists on paper. Hard copies can be useful for the following reasons: CONSIDER THIS Creating a Worksheet and a Chart Excel Module 1 EX 1-53 EX 1-54 Excel Module 1 Creating a Worksheet and a Chart Print screen presents several print options and shows a preview of how workbook will print Worksheet preview Copies box Printer Status button Print tab options in your Settings area may differ, depending on type of printer you are using specify pages to print Portrait Orientation button click to select paper size No Scaling button Next Page button scrolls preview forward to next page Previous Page button scrolls preview backward to previous page Figure 1–83 2 • Verify that the printer listed on the Printer Status button is the printer you want to use. If necessary, click the Printer Status button to display a list of available printer options and then click the desired printer to change the currently selected printer. • If you want to print more than one copy, use the Copies up arrow to increase the number. • If you want to change the paper size, use the paper size arrow (which currently reads Letter 8.5" × 11") to view and select a different one. 3 • Click the Portrait Orientation button in the Settings area and then select Landscape Orientation to change the orientation of the page to landscape. • Click the No Scaling button and then select ‘Fit Sheet on One Page’ to print the entire worksheet on one page (Figure 1–84). Print button name of currently selected printer — your printer name will differ preview of how workbook will look with printed ‘Fit Sheet on One Page’ selected Figure 1–84 4 • Click the Print button on the Print screen to print the worksheet in landscape orientation on the currently selected printer. Q&A • When the printer stops, retrieve the hard copy (Figure 1–85). Do I have to wait until my worksheet is complete to print it? No, you can print a document at any time while you are creating it. Figure 1–85 Other Ways 1. Press CTRL+P to open the Print screen, press ENTER Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-55 EX 1-56 Excel Module 1 Creating a Worksheet and a Chart Viewing Automatic Calculations You can easily view calculations using the AutoCalculate area, an area on the Excel status bar where you can view a total, an average, or other information about a selected range. First, select the range of cells containing the numbers you want to check. Next, right-click the AutoCalculate area to display the Customize Status Bar shortcut menu (Figure 1–86). The check marks indicate that the calculations are displayed in the status bar; more than one may be selected. The functions of the AutoCalculate commands on the Customize Status Bar shortcut menu are described in Table 1–5. Table 1–5 Commonly Used Status Bar Commands Command Function Average AutoCalculate area displays the average of the numbers in the selected range Count AutoCalculate area displays the number of nonempty cells in the selected range Numerical Count AutoCalculate area displays the number of cells containing numbers in the selected range Minimum AutoCalculate area displays the lowest value in the selected range Maximum AutoCalculate area displays the highest value in the selected range Sum AutoCalculate area displays the sum of the numbers in the selected range To Use the AutoCalculate Area to Determine a Maximum The following steps determine the largest monthly total in the budget. Why? Sometimes, you want a quick analysis, which can be especially helpful when your worksheet contains a lot of data. 1 • Select the range B19:M19. Right-click the status bar to display the Customize Status Bar shortcut menu (Figure 1–86). Customize Status Bar shortcut menu check mark indicates calculation appears on status bar Maximum command status bar Figure 1–86 2 • Click Maximum on the shortcut menu to display the Maximum value in the range B19:M19 in the AutoCalculate area of the status bar. • Click anywhere on the worksheet to close the shortcut menu (Figure 1–87). maximum value displayed in AutoCalculate area Figure 1–87 3 • Right-click the AutoCalculate area and then click Maximum on the shortcut menu to deselect it. The Maximum value will no longer appear on the status bar. • Close the shortcut menu. Correcting Errors You can correct data entry errors on a worksheet using one of several methods. The method you choose will depend on the extent of the error and whether you notice it while entering the data or after you have entered the incorrect data into the cell. Correcting Errors while Entering Data into a Cell If you notice an error while you are entering data into a cell, press backspace to erase the incorrect character(s) and then enter the correct character(s). If the error is a major one, click the Cancel box in the formula bar or press esc to erase the entire entry and then reenter the data. Correcting Errors after Entering Data into a Cell If you find an error in the worksheet after entering the data, you can correct the error in one of two ways: 1. If the entry is short, select the cell, retype the entry correctly, and then click the Enter button or press enter. The new entry will replace the old entry. 2. If the entry in the cell is long and the errors are minor, using Edit mode may be a better choice than retyping the cell entry. In Edit mode, a mode that lets you perform in-cell editing, Excel displays the active cell entry in the formula bar and a flashing insertion point in the active cell. There you can edit the contents directly in the cell — a procedure called in-cell editing. a. Double-click the cell containing the error to switch Excel to Edit mode (Figure 1–88). Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-57 EX 1-58 Excel Module 1 Creating a Worksheet and a Chart in-cell editing Figure 1 – 88 b. Make corrections using the following in-cell editing methods. (1) To insert new characters between two characters, place the insertion point between the two characters and begin typing. Excel inserts the new characters to the left of the insertion point. (2) To delete a character in the cell, move the insertion point to the left of the character you want to delete and then press delete, or place the insertion point to the right of the character you want to delete and then press backspace. You also can drag to select the character or adjacent characters you want to delete and then press delete or ctrl+x or click the Cut button (Home tab | Clipboard group). (3) When you are finished editing an entry, click the Enter button or press enter. There are two ways to enter data in Edit mode: Insert mode and Overtype mode. Insert mode is the default Excel mode that inserts a character and moves all characters to the right of the typed character one position to the right. You can change to Overtype mode by pressing insert. In Overtype mode, Excel replaces, or overtypes, the character to the right of the insertion point. The insert key toggles the keyboard between Insert mode and Overtype mode. While in Edit mode, you may want to move the insertion point to various points in the cell, select portions of the data in the cell, or switch from inserting characters to overtyping characters. Table 1–6 summarizes the more common tasks performed during in-cell editing. Table 1–6 Summary of In-Cell Editing Tasks Task Mouse Operation Keyboard 1. Move the insertion point to Point to the left of the first character the beginning of data in a cell. and click. Press home. 2. Move the insertion point to the end of data in a cell. Point to the right of the last character and click. Press end. 3. Point to the appropriate position and click the character. Drag through adjacent characters. 5. Move the insertion point anywhere in a cell. Highlight one or more adjacent characters. Select all data in a cell. 6. Delete selected characters. 7. Delete characters to the left of the insertion point. Press backspace. 8. Delete characters to the right of the insertion point. Press delete. 9. Toggle between Insert and Overtype modes. Press insert. 4. Press right arrow or left arrow. Press shift+right arrow or shift+left arrow. Double-click the cell with the insertion point in the cell if the data in the cell contains no spaces. Click the Cut button (Home tab | Clipboard Press delete. group). Undoing the Last Cell Entry The Undo button on the Quick Access Toolbar (Figure 1–89) allows you to erase recent cell entries. Thus, if you enter incorrect data in a cell and notice it immediately, click the Undo button and Excel changes the cell entry to what it was prior to the incorrect data entry. Undo button Undo list Figure 1–89 Excel remembers the last 100 actions you have completed. Thus, you can undo up to 100 previous actions by clicking the Undo arrow to display the Undo list and then clicking the action to be undone (Figure 1–89). You can drag through several actions in the Undo list to undo all of them at once. If no actions are available for Excel to undo, then the dimmed appearance of the Undo button indicates that it is unavailable. The Redo button, next to the Undo button on the Quick Access Toolbar, allows you to repeat previous actions; that is, if you accidentally undo an action, you can use the Redo button to perform the action again. Clearing a Cell or Range of Cells If you enter data into the wrong cell or range of cells, you can erase, or clear, the data using one of the first four methods listed below. The fifth method clears the formatting from the selected cells. To clear a cell or range of cells, you would perform the following steps: TO CLEAR CELL ENTRIES USING THE FILL HANDLE 1. Select the cell or range of cells and then point to the fill handle so that the pointer changes to a crosshair. 2. Drag the fill handle back into the selected cell or range until a shadow covers the cell or cells you want to erase. TO CLEAR CELL ENTRIES USING THE SHORTCUT MENU 1. Select the cell or range of cells to be cleared. 2. Right-click the selection. 3. Click Clear Contents on the shortcut menu. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-59 EX 1-60 Excel Module 1 Creating a Worksheet and a Chart TO CLEAR CELL ENTRIES USING THE DELETE KEY 1. Select the cell or range of cells to be cleared. 2. Press delete. TO CLEAR CELL ENTRIES AND FORMATTING USING THE CLEAR BUTTON 1. Select the cell or range of cells to be cleared. 2. Click the Clear button (Home tab | Editing group). 3. Click Clear Contents on the Clear menu, or click Clear All to clear both the cell entry and the cell formatting. TO CLEAR FORMATTING USING THE CELL STYLES BUTTON 1. Select the cell or range of cells from which you want to remove the formatting. 2. Click the Cell Styles button (Home tab | Styles group) and then click Normal in the Cell Styles gallery. As you are clearing cell entries, always remember that you should never press the SPACEBAR to clear a cell. Pressing the spacebar enters a blank character. A blank character is interpreted by Excel as text and is different from an empty cell, even though the cell may appear empty. Clearing the Entire Worksheet If the required worksheet edits are extensive or if the requirements drastically change, you may want to clear the entire worksheet and start over. To clear the worksheet or delete an embedded chart, you would use the following steps. TO CLEAR THE ENTIRE WORKSHEET 1. Click the Select All button on the worksheet. The Select All button is located above the row 1 identifier and to the left of the column A heading. 2. Click the Clear button (Home tab | Editing group) and then click Clear All on the menu to delete both the entries and formats. The Select All button selects the entire worksheet. To clear an unsaved workbook, click the Close Window button on the workbook’s title bar or click the Close button in Backstage view. Click the No button if the Microsoft Excel dialog box asks if you want to save changes. To start a new, blank workbook, click the New button in Backstage view. Using Excel Help Once an Office app’s Help window is open, you can use several methods to navigate Help. You can search for help by using the Help pane or the Tell me box. To Obtain Help Using the Search Text Box Assume for the following example that you want to know more about functions. The following steps use the Search text box to obtain useful information about functions by entering the word, functions, as search text. Why? You may not know the exact help topic you are looking to find, so using keywords can help narrow your search. 1 • Click Help on the ribbon to display the Help tab (Figure 1–90). Help tab available commands to obtain help Figure 1–90 2 • Click the Help button (Help group) to display the Help pane (Figure 1–91). Help button Help pane Help group Figure 1–91 Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-61 EX 1-62 Excel Module 1 Creating a Worksheet and a Chart 3 • Type functions in the Search help box at functions entered in Search box the top of the Help pane to enter the search text (Figure 1–92). Figure 1–92 4 • Press ENTER to display the search results Q&A (Figure 1–93). Why do my search results differ? If you do not have an Internet connection, your results will reflect only the content of the Help files on your computer. When searching for help online, results also can change as content is added, deleted, and updated on the online Help webpages maintained by Microsoft. Why were my search results not very helpful? When initiating a search, be sure to check the spelling of the search text; also, keep your search specific to return the most accurate results. ‘Excel functions (by category)’ link search results Figure 1–93 5 Close button • Click the ‘Excel functions (by category)’, or similar, link to display the Help information associated with the selected topic (Figure 1–94). Help information Figure 1–94 6 • Click the Close button in the Help pane to close the pane. • Click Home on the ribbon to display the Home tab. Obtaining Help while Working in an Office App You also can access the Help functionality without first opening the Help pane and initiating a search. For example, you may be confused about how a particular command works, or you may be presented with a dialog box that you are not sure how to use. If you want to learn more about a command, point to its button and wait for the ScreenTip to appear, as shown in Figure 1–95. If the Help icon and ‘Tell me more’ link appear in the ScreenTip, click the ‘Tell me more’ link (or press f1 while pointing to the button) to open the Help window associated with that command. Dialog boxes also contain Help buttons, as shown in Figure 1–96. Clicking the Help button (or pressing f1) while the dialog box is displayed opens a Help window, which will display help contents specific to the dialog box, if available. If no help file is available for that particular dialog box, then the window will display the Help home page. As mentioned previously, the Tell me box is integrated into the ribbon in Excel and most other Office apps and can perform a variety of functions, including providing easy access to commands and help content as you type. Format Painter button Help button in ScreenTip Figure 1–95 Help button in dialog box Figure 1–96 To Obtain Help Using the Tell Me Box If you are having trouble finding a command in Excel, you can use the Tell me box to search for the function you are trying to perform. As you type, the Tell me box will suggest commands that match the search text you are entering. Why? You can use the Tell me box to access commands quickly you otherwise may be unable to find on the ribbon. The following steps find commands related to headers and footers. 1 • Type header and footer in the Tell me box and watch the search results appear (Figure 1–97). Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-63 EX 1-64 Excel Module 1 Creating a Worksheet and a Chart search text in Tell Me box commands related to search text Figure 1–97 To Save a Workbook with a Different File Name To save a copy of the existing file, you can save the file with a new file name. Why? You have finished working on the Frangold Real Estate Budget workbook and would like to save a copy of the workbook with a new file name. The following steps save the Frangold Real Estate Budget workbook with a new file name. 1 Click File on the ribbon to open Backstage view. 2 Click Save As in Backstage view to display the Save As screen. 3 Type SC_EX_1_Frangold in the File name text box, replacing the existing file name. 4 Click the Save button to save the workbook with the new name. To Sign Out of a Microsoft Account Click File on the ribbon to open Backstage view. 2 Click Account to display the Account screen (Figure 1–98). 3 Click the Sign out link, which displays the Remove Account dialog box. If a Can’t remove Windows accounts dialog box appears instead of the Remove Account dialog box, click OK and skip the remaining steps. Why does a Can’t remove Windows accounts dialog box appear? If you signed in to Windows using your Microsoft account, then you also must sign out from Windows rather than signing out from within Excel. When you are finished using Windows, be sure to sign out at that time. 4 Click the Yes button (Remove Account dialog box) to sign out of your Microsoft account on this computer. Q&A 1 Q&A If you are using a public computer or otherwise want to sign out of your Microsoft account, you should sign out of the account from the Accounts screen in Backstage view. Why? For security reasons, you should sign out of your Microsoft account when you are finished using a public or shared computer. Staying signed in to your Microsoft account might enable others to access your files. The following steps sign out of a Microsoft account and exit the Excel program. If you do not want to sign out of your Microsoft account or exit Excel, read these steps without performing them. Should I sign out of Windows after removing my Microsoft account? When you are finished using the computer, you should sign out of Windows for maximum security. account currently signed in to Microsoft Office Account screen Sign out link your software version may differ Account tab Figure 1–98 5 Click the Back button in the upper-left corner of Backstage view to return to the document. 6 Click the Close button to close the workbook and exit Microsoft Excel. If you are prompted to save changes, click Yes. Summary CONSIDER THIS: PLAN AHEAD In this module you have learned how to create a real estate budget worksheet and chart. Topics covered included starting Excel and creating a blank workbook, selecting a cell, entering text, entering numbers, calculating a sum, using the fill handle, formatting a worksheet, adding a pie chart, changing sheet tab names and colors, printing a worksheet, using the AutoCalculate area, correcting errors, and obtaining help. What decisions will you need to make when creating workbooks and charts in the future? Use these guidelines as you complete the assignments in this module and create your own spreadsheets outside of this class. 1. Determine the workbook structure. a) Determine the data you will need for your workbook. b) Sketch a layout of your data and your chart. 2. Create the worksheet. a) Enter titles, subtitles, and headings. b) Enter data, functions, and formulas. 3. Format the worksheet. a) Format the titles, subtitles, and headings using styles. b) Format the totals. c) Format the numbers. d) Format the text. e) Adjust column widths. 4. Create the chart. a) Determine the type of chart to use. b) Determine the chart title and data. c) Determine the chart location d) Format the chart. Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-65 STUDENT ASSIGNMENTS EX 1-66 Excel Module 1 Creating a Worksheet and a Chart Apply Your Knowledge Reinforce the skills and apply the concepts you learned in this module. Changing the Values in a Worksheet Note: To complete this assignment, you will be required to use the Data Files. Please contact your instructor for information about accessing the Data Files. Instructions: Start Excel. Open the workbook called SC_EX_1-1.xlsx (Figure 1–99a), which is located in the Data Files. The workbook you open contains sales data for Delton Discount. You are to edit data, apply formatting to the worksheet, and move the chart to a new sheet tab. Perform the following tasks: 1. Make the changes to the worksheet described in Table 1–7. As you edit the values in the cells containing numeric data, watch the totals in row 8, the totals in column H, and the chart change. Table 1–7 New Worksheet Data Cell Change Cell Contents To A2 Monthly Departmental Sales B5 13442.36 C7 115528.13 D5 24757.85 E6 39651.54 F7 29667.88 G6 19585.46 2. Change the worksheet title in cell A1 to the Title cell style and then merge and center it across columns A through H. 3. Use buttons in the Font group on the Home tab on the ribbon to change the worksheet subtitle in cell A2 to 14-point font and then merge and center it across columns A through H. Change the font color of cell A2 to Blue, Accent 1, Darker 50%. 4. Name the worksheet, Department Sales, and apply the Blue, Accent 1, Darker 50% color to the sheet tab (Figure 1–99b). 5. Move the chart to a new sheet called Sales Analysis Chart (Figure 1–99c). Change the chart title to MONTHLY SALES TOTALS. If requested by your instructor, on the Department Sales worksheet, replace Delton in cell A1 with your last name. 6. Save the workbook with the file name, SC_EX_1_Delton, and submit the revised workbook (shown in Figure 1–99) in the format specified by your instructor and exit Excel. 7. Besides the styles used in the worksheet, what other changes could you make to enhance the worksheet? (a) Worksheet before Formatting (b) Worksheet after Formatting (c) Pie Chart on Separate Sheet Figure 1–99 STUDENT ASSIGNMENTS Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-67 STUDENT ASSIGNMENTS EX 1-68 Excel Module 1 Creating a Worksheet and a Chart Extend Your Knowledge Extend the skills you learned in this module and experiment with new skills. You may need to use Help to complete the assignment. Creating Styles and Formatting a Worksheet Note: To complete this assignment, you will be required to use the Data Files. Please contact your instructor for information about accessing the Data Files. Instructions: Start Excel. Open the workbook called SC_EX_1-2.xlsx, which is located in the Data Files. The workbook you open contains sales data for Harolamer Electronics. You are to create styles and format a worksheet using them. Perform the following tasks: 1. Select cell A4. Use the New Cell Style command in the Cell Styles gallery open the Style dialog box (Figure 1-100). Create a style that uses the Orange, Accent 2 font color (row 1, column 6). Name the style, MyHeadings. 2. Select cell A5. Use the New Cell style dialog box to create a style that uses the Orange, Accent 2, Darker 50% (row 6, column 6) font color. Name the style, MyRows. 3. Select cell ranges B4:G4 and A5:A8. Apply the MyHeadings style to the cell ranges. 4. Select the cell range B5:G7. Apply the MyRows style to the cell range. 5. Name the sheet tab and apply a color of your choice. If requested by your instructor, change the font color of the text in cells A1 and A2 to the color of your eyes. 6. Save the workbook with the file name, SC_EX_1_Harolamer, and submit the revised workbook in the format specified by your instructor, and then exit Excel. 7. What other styles would you create to improve the worksheet’s appearance? Figure 1–100 Expand Your World Create a solution that uses cloud or web technologies by learning and investigating on your own from general guidance. Loan Calculator Instructions: Start Excel. You are to determine how long it will take you to pay back a loan. You decide to download and use one of the Excel templates to create your worksheet. Perform the following tasks: 1. Click New in Backstage view and then search for and click a template that can calculate loans for an item you choose, such as a vehicle, mortgage, or general loan. 2. Enter fictitious (but realistic) information for a loan, including loan number, lender, loan amount, annual interest rate, beginning date, and length (in years). If the template you chose does not include a place for this information, add the information in an appropriate location. Search the web to examine current interest rates and typical loan durations. 3. Save the file as SC_EX_1_LoanCalculator, print the worksheet, and submit the assignment in the format specified by your instructor and then exit Excel. 4. Which template would you use if you wanted to plan and keep track of a budget for a wedding? In the Lab Design and implement a solution using creative thinking and problem-solving skills. Create a Worksheet Comparing Laptops Problem: You are shopping for a new laptop and want to compare the prices of three laptops. You will compare laptops with similar specifications, but where the brands and/or models are different. Perform the following tasks: Part 1: Create a worksheet that compares the type, specifications, and the price for each laptop, as well as the costs to add an extended warranty. Use the concepts and techniques presented in this module to calculate the average price of a laptop and average cost of an extended warranty and to format the worksheet. Include a chart to compare the different laptop costs. Submit your assignment in the format specified by your instructor. You made several decisions while creating the worksheet in this assignment: how to organize the data, how to display the text, which calculations to use, and which chart to use. What was your rationale behind each of these decisions? Part 2: STUDENT ASSIGNMENTS Excel Module 1 Creating a Worksheet and a Chart Excel Module 1 EX 1-69 Chapter Introduction After completing this chapter, you will be able to Describe the basic features of an algorithm Explain how hardware and software collaborate in a computer’s architecture Summarize a brief history of computing Compose and run a simple Python program 1 A Not-So-Brief History of Computing Systems A programmer typically starts by writing high-level language statements in a text editor. The programmer then runs another program called a translator to convert the high-level program code into executable code. Because it is possible for a programmer to make grammatical mistakes even when writing high-level code, the translator checks for syntax errors before it completes the translation process. If it detects any of these errors, the translator alerts the programmer via error messages. The programmer then has to revise the program. If the translation process succeeds without a syntax error, the program can be executed by the run-time system. The run-time system might execute the program directly on the hardware or run yet another program called an interpreter or virtual machine to execute the program. Figure 1-3 shows the steps and software used in the coding process. Text editor Translator Syntax error messages Create high-level language program User inputs Run-time system Other error messages Program outputs Figure 1-3 Software used in the coding process exercises 1. List two examples of input devices and two examples of output devices. 2. What does the central processing unit (CPU) do? 3. How is information represented in hardware memory? 4. What is the difference between a terminal-based interface and a graphical user interface? 5. What role do translators play in the programming process? a Not-So-Brief history of Computing Systems Now that we have in mind some of the basic ideas of computing and computer systems, let’s take a moment to examine how they have taken shape in history. Figure 1-4 summarizes some of the major developments in the history of computing. The discussion that follows provides more details about these developments. 9 Chapter 1 Introduction approximate Dates Major Developments Before 1800 • Mathematicians discover and use algorithms • Abacus used as a calculating aid • First mechanical calculators built by Pascal and Leibniz • Jacquard’s loom • Babbage’s Analytical Engine • Boole’s system of logic • Hollerith’s punch card machine • Turing publishes results on computability 10 19 Century th 1930s • Shannon’s theory of information and digital switching 1940s • First electronic digital computers 1950s • First symbolic programming languages • Transistors make computers smaller, faster, more durable, and less expensive • Emergence of data processing applications • Integrated circuits accelerate the miniaturization of hardware • First minicomputers • Time-sharing operating systems • Interactive user interfaces with keyboard and monitor • Proliferation of high-level programming languages • Emergence of a software industry and the academic study of computer science • First microcomputers and mass-produced personal computers • Graphical user interfaces become widespread • Networks and the Internet • Optical storage for multimedia applications, images, sound, and video • World Wide Web, Web applications, and e-commerce • Laptops • Wireless computing, smartphones, and mobile applications • Computers embedded and networked in an enormous variety of cars, household appliances, and industrial equipment • Social networking, use of big data in finance and commerce • Digital streaming of music and video 1960–1975 1975–1990 1990–2000 2000–present Figure 1-4 Summary of major developments in the history of computing A Not-So-Brief History of Computing Systems Before Electronic Digital Computers Ancient mathematicians developed the first algorithms. The word “algorithm” comes from the name of a Persian mathematician, Muhammad ibn Musa al-Khwarizmi, who wrote several mathematics textbooks in the ninth century. About 2,300 years ago, the Greek mathematician Euclid, the inventor of geometry, developed an algorithm for computing the greatest common divisor of two numbers. [b] Pascal’s Calculator Image © Mary Evans/Photo Researchers, Inc. [a] Abacus Image © Lim ChewHow, 2008. Used under license from Shutterstock.com. A device known as the abacus also appeared in ancient times. The abacus helped people perform simple arithmetic. Users calculated sums and differences by sliding beads on a grid of wires (see Figure 1-5a). The configuration of beads on the abacus served as the data. Figure 1-5 Some early computing devices 11 Chapter 1 Introduction [c] Jacquard’s Loom Image © Roger Viollet/Getty Images 12 Figure 1-5 (Continued) In the seventeenth century, the French mathematician Blaise Pascal (1623–1662) built one of the first mechanical devices to automate the process of addition (see Figure 1-5b). The addition operation was embedded in the configuration of gears within the machine. The user entered the two numbers to be added by rotating some wheels. The sum or output number appeared on another rotating wheel. The German mathematician Gottfried Wilhelm Leibniz (1646–1716) built another mechanical calculator that included other arithmetic functions such as multiplication. Leibniz, who with Newton also invented calculus, went on to propose the idea of computing with symbols as one of our most basic and general intellectual activities. He argued for a universal language in which one could solve any problem by calculating. Early in the nineteenth century, the French engineer Joseph-Marie Jacquard (1752–1834) designed and constructed a machine that automated the process of weaving (see Figure 1-5c). Until then, each row in a weaving pattern had to be set up by hand, a quite tedious, errorprone process. Jacquard’s loom was designed to accept input in the form of a set of punched cards. Each card described a row in a pattern of cloth. Although it was still an entirely mechanical device, Jacquard’s loom possessed something that previous devices had lacked— the ability to execute an algorithm automatically. The set of cards expressed the algorithm or set of instructions that controlled the behavior of the loom. If the loom operator wanted to produce a different pattern, he just had to run the machine with a different set of cards. Chapter 2 SOFTWARE DEVELOPMENT, Data Types, and Expressions After completing this chapter, you will be able to Describe the basic phases of software development: analysis, design, coding, and testing Use strings for the terminal input and output of text Use integers and floating-point numbers in arithmetic operations Construct arithmetic expressions Initialize and use variables with appropriate names Import functions from library modules Call functions with arguments and use returned values appropriately Construct a simple Python program that performs inputs, calculations, and outputs Use docstrings to document Python programs The Software Development Process This chapter begins with a discussion of the software development process, followed by a case study in which we walk through the steps of program analysis, design, coding, and testing. We also examine the basic elements from which programs are composed. These include the data types for text and numbers and the expressions that manipulate them. The chapter concludes with an introduction to the use of functions and modules in simple programs. 35 the Software Development process There is much more to programming than writing lines of code, just as there is more to building houses than pounding nails. The “more” consists of organization and planning, and various conventions for diagramming those plans. Computer scientists refer to the process of planning and organizing a program as software development. There are several approaches to software development. One version is known as the waterfall model. The waterfall model consists of several phases: 1. Customer request—In this phase, the programmers receive a broad statement of a problem that is potentially amenable to a computerized solution. This step is also called the user requirements phase. 2. analysis—The programmers determine what the program will do. This is some- times viewed as a process of clarifying the specifications for the problem. 3. Design—The programmers determine how the program will do its task. 4. Implementation—The programmers write the program. This step is also called the coding phase. 5. Integration—Large programs have many parts. In the integration phase, these parts are brought together into a smoothly functioning whole, usually not an easy task. 6. Maintenance—Programs usually have a long life; a life span of 5 to 15 years is com- mon for software. During this time, requirements change, errors are detected, and minor or major modifications are made. The phases of the waterfall model are shown in Figure 2-1. As you can see, the figure resembles a waterfall, in which the results of each phase flow down to the next. However, a mistake detected in one phase often requires the developer to back up and redo some of the work in the previous phase. Modifications made during maintenance also require backing up to earlier phases. Taken together, these phases are also called the software development life cycle. Although the diagram depicts distinct phases, this does not mean that developers must analyze and design a complete system before coding it. Modern software development is usually incremental and iterative. This means that analysis and design may produce a rough draft, skeletal version, or prototype of a system for coding, and then back up to earlier phases to fill in more details after some testing. For purposes of introducing this process, however, we treat these phases as distinct. Programs rarely work as hoped the first time they are run; hence, they should be subjected to extensive and careful testing. Many people think that testing is an activity that applies only to the implementation and integration phases; however, you should scrutinize the SOFTWARE DEVELOPMENT, Data Types, and Expressions Chapter 2 Customer request Verify Analysis 36 Verify Design Verify Implementation Test Integration Test Maintenance Figure 2-1 The waterfall model of the software development process outputs of each phase carefully. Keep in mind that mistakes found early are much less expensive to correct than those found late. Figure 2-2 illustrates some relative costs of repairing mistakes when found in different phases. These are not just financial costs but also costs in time and effort. Cost of Correcting a Fault Analysis Design Implementation Integration Maintenance Software Development Phase Figure 2-2 Relative costs of repairing mistakes that are found in different phases The Software Development Process Keep in mind that the cost of developing software is not spread equally over the phases. The percentages shown in Figure 2-3 are typical. Integration 8% 37 Implementation 8% Design 8% Analysis 8% Maintenance 68% Figure 2-3 Percentage of total cost incurred in each phase of the development process You might think that implementation takes the most time and therefore costs the most. However, as you can see in Figure 2-3, maintenance is the most expensive part of software development. The cost of maintenance can be reduced by careful analysis, design, and implementation. As you read this book and begin to sharpen your programming skills, you should remember two points: 1. There is more to software development than writing code. 2. If you want to reduce the overall cost of software development, write programs that are easy to maintain. This requires thorough analysis, careful design, and a good coding style. We will have more to say about coding styles throughout the book. exercises 1. List four phases of the software development process, and explain what they accomplish. 2. Jack says that he will not bother with analysis and design but proceed directly to coding his programs. Why is that not a good idea? Chapter 2 SOFTWARE DEVELOPMENT, Data Types, and Expressions CaSe StuDy: Income Tax Calculator 38 Most of the chapters in this book include a case study that illustrates the software development process. This approach may seem overly elaborate for small programs, but it scales up well when programs become larger. The first case study develops a program that calculates income tax. Each year, nearly everyone with an income faces the unpleasant task of computing his or her income tax return. If only it could be done as easily as suggested in this case study! We start with the customer request phase. request The customer requests a program that computes a person’s income tax. analysis Analysis often requires the programmer to learn some things about the problem domain, in this case, the relevant tax law. For the sake of simplicity, let’s assume the following tax laws: • All taxpayers are charged a flat tax rate of 20%. • All taxpayers are allowed a $10,000 standard deduction. • For each dependent, a taxpayer is allowed an additional $3,000 deduction. • Gross income must be entered to the nearest penny. • The income tax is expressed as a decimal number. Another part of analysis determines what information the user will have to provide. In this case, the user inputs are gross income and number of dependents. The program calculates the income tax based on the inputs and the tax law and then displays the income tax. Figure 2-4 shows the proposed terminal-based interface. Characters in italics indicate user inputs. The program prints the rest. The inclusion of an interface at this point is a good idea because it allows the customer and the programmer to discuss the intended program’s behavior in a context understandable to both. Enter the gross income: 150000.00 Enter the number of dependents: 3 The income tax is $26200.0 Figure 2-4 The user interface for the income tax calculator (continues) The Software Development Process (continued ) Design During analysis, we specify what a program is going to do. In the next phase, design, we describe how the program is going to do it. This usually involves writing an algorithm. In Chapter 1, we showed how to write algorithms in ordinary English. In fact, algorithms are more often written in a somewhat stylized version of English called pseudocode. Here is the pseudocode for our income tax program: Input the gross income and number of dependents Compute the taxable income using the formula Taxable income = gross income - 10000 - (3000 * number of dependents) Compute the income tax using the formula Tax = taxable income * 0.20 Print the tax Although there are no precise rules governing the syntax of pseudocode, in your pseudocode you should strive to describe the essential elements of the program in a clear and concise manner. Note that this pseudocode closely resembles Python code, so the transition to the coding step should be straightforward. Implementation (Coding) Given the preceding pseudocode, an experienced programmer would now find it easy to write the corresponding Python program. For a beginner, on the other hand, writing the code can be the most difficult part of the process. Although the program that follows is simple by most standards, do not expect to understand every bit of it at first. The rest of this chapter explains the elements that make it work, and much more. """ Program: taxform.py Author: Ken Lambert Compute a person’s income tax. 1. Significant constants tax rate standard deduction deduction per dependent 2. The inputs are gross income number of dependents 3. Computations: taxable income = gross income - the standard deduction - a deduction for each dependent income tax = is a fixed percentage of the taxable income 4. The outputs are the income tax """ (continues) 39 Chapter 2 SOFTWARE DEVELOPMENT, Data Types, and Expressions (continued ) 40 # Initialize the constants TAX_RATE = 0.20 STANDARD_DEDUCTION = 10000.0 DEPENDENT_DEDUCTION = 3000.0 # Request the inputs grossIncome = float(input("Enter the gross income: ")) numDependents = int(input("Enter the number of dependents: ")) # Compute the income tax taxableIncome = grossIncome - STANDARD_DEDUCTION - \ DEPENDENT_DEDUCTION * numDependents incomeTax = taxableIncome * TAX_RATE # Display the income tax print("The income tax is $" + str(incomeTax)) testing Our income tax program can run as a script from an IDLE window. If there are no syntax errors, we will be able to enter a set of inputs and view the results. However, a single run without syntax errors and with correct outputs provides just a slight indication of a program’s correctness. Only thorough testing can build confidence that a program is working correctly. Testing is a deliberate process that requires some planning and discipline on the programmer’s part. It would be much easier to turn the program in after the first successful run to meet a deadline or to move on to the next assignment. But your grade, your job, or people’s lives might be affected by the slipshod testing of software. Testing can be performed easily from an IDLE window. The programmer just loads the program repeatedly into the shell and enters different sets of inputs. The real challenge is coming up with sets of inputs that can reveal an error. An error at this point, also called a logic error or a design error, is an unexpected output. A correct program produces the expected output for any legitimate input. The tax calculator’s analysis does not provide a specification of what inputs are legitimate, but common sense indicates that they would be numbers greater than or equal to 0. Some of these inputs will produce outputs that are less than 0, but we will assume for now that these outputs are expected. Even though the range of the input numbers on a computer is finite, testing all of the possible combinations of inputs would be impractical. The challenge is to find a smaller set of inputs, called a test suite, from which we can conclude that the program will likely be correct for all inputs. In the tax program, we try inputs of 0, 1, and 2 for the number of dependents. If the program works correctly with these, we can assume that it will work correctly with larger values. The test inputs for the gross income are a number equal to the standard deduction and a number twice that amount (10000 and 20000, respectively). These two values will show the cases of a minimum (continues) Strings, Assignment, and Comments (continued ) expected tax (0) and expected taxes that are less than or greater than 0. The program is run with each possible combination of the two inputs. Table 2-1 shows the possible combinations of inputs and the expected outputs in the test suite. 41 Number of Dependents Gross Income expected tax 0 10000 0 1 10000 –600 2 10000 –1200 0 20000 2000 1 20000 1400 2 20000 800 table 2-1 The test suite for the tax calculator program If there is a logic error in the code, it will almost certainly be caught using these data. Note that the negative outputs are not considered errors. We will see how to prevent such computations in the next chapter. Strings, assignment, and Comments Text processing is by far the most common application of computing. E-mail, text messaging, Web pages, and word processing all rely on and manipulate data consisting of strings of characters. This section introduces the use of strings for the output of text and the documentation of Python programs. We begin with an introduction to data types in general. Data Types In the real world, we use data all the time without bothering to consider what kind of data we’re using. For example, consider this sentence: “In 2007, Micaela paid $120,000 for her house at 24 East Maple Street.” This sentence includes at least four pieces of data—a name, a date, a price, and an address—but of course you don’t have to stop to think about that before you utter the sentence. You certainly don’t have to stop to consider that the name consists only of text characters, the date and house price are numbers, and so on. However, when we use data in a computer program, we do need to keep in mind the type of data we’re using. We also need to keep in mind what we can do with (what operations can be performed on) particular data. In programming, a data type consists of a set of values and a set of operations that can be performed on those values. A literal is the way a value of a data type looks to a programmer. The programmer can use a literal in a program to mention a data value. When the