TABLE OF CONTENTS

CHAPTER 1 Computer Programming and the Workplace...... 1 1.1 Concepts and Terminology of a Computer...... 2 1.2 Exploring Careers and the Marketplace...... 7 1.3 Employability Skills...... 10 1.4 Ethical Responsibilities ...... 14

CHAPTER 2 Comparing Programming Languages and Creating Your First Java Program. .21 2.1 Types of Programming Languages and Their Uses...... 22 2.2 Developing a Modular Design for Your Application...... 25 2.3 The Evolution of Styles...... 26 2.4 Creating Your First Java Program...... 29 2.5 Creating, Compiling, and Executing a Java Program ...... 33 2.6 Documenting Your Program Using a Defined Standard and Style...... 36 2.7 Testing Your Program and Understanding Programming Errors...... 38 2.8 Developing Java Programs Using NetBeans ...... 42 2.9 Developing Java Programs Using Eclipse...... 44

CHAPTER 3 Programming Techniques to Analyze and Solve Problems...... 51 3.1 Introduction ...... 52 3.2 Writing a Simple Program...... 52 3.3 Identifying Input Requirements and Reading from the Console...... 55 3.4 Identifiers ...... 59 3.5 Variables...... 60 3.6 Assignment Statements and Assignment Expressions...... 61 3.7 Named Constants ...... 63 3.8 Follow Defined Standards to Document Your Design ...... 64 3.9 Numeric Data Types and Operations...... 65 3.10 Evaluating Expressions and Operator Precedence...... 67 3.11 Case Study: Displaying the Current Time...... 69

v

A01_CP_FM.indd 5 3/29/17 1:11 PM vi Table of Contents

3.12 Augmented Assignment Operators ...... 71 3.13 Increment and Decrement Operators...... 72 3.14 Numeric Type Conversions ...... 74 3.15 Developing a Project Plan Using the Software Development Life Cycle Process...... 77 3.16 Applying the Software Development Life Cycle Process...... 78 3.17 Case Study: Counting Monetary Units...... 82 3.18 Testing Your Program for Common Errors and Pitfalls...... 85

CHAPTER 4 Using Selection Statements...... 93 4.1 Introduction ...... 94 4.2 boolean Data Type...... 94 4.3 if Statements...... 96 4.4 Two-Way if-else Statements ...... 99 4.5 Nested if and Mult-Way if-else Statements...... 100 4.6 Identifying Common Software Development Issues and Errors...... 102 4.7 Generating Random Numbers...... 107 4.8 Case Study: Computing Body Mass Index ...... 109 4.9 Case Study: Computing Taxes ...... 110 4.10 Logical Operators...... 113 4.11 Case Study: Determining Leap Year...... 118 4.12 Case Study: Lottery...... 119 4.13 switch Statements...... 121 4.14 Conditional Expressions...... 124 4.15 Operator Precedence and Associativity...... 126 4.16 Troubleshooting Issues Using Debugging...... 127

CHAPTER 5 Working with Characters and Strings...... 133 5.1 Introduction ...... 134 5.2 Character Data Type and Operations...... 134 5.3 The String Type ...... 138 5.4 Identifying Software Application Constraints...... 148 5.5 Case Studies...... 149 5.6 Formatting Console Output...... 157

A01_CP_FM.indd 6 3/29/17 1:11 PM Table of Contents vii

CHAPTER 6 Using Loop Statements...... 167 6.1 Introduction ...... 168 6.2 The while Loop ...... 168 6.3 The do-while Loop ...... 179 6.4 The for Loop...... 181 6.5 Which Loop to Use? ...... 185 6.6 Case Studies...... 187 6.7 Keywords break and continue...... 190 6.8 Case Study: Checking Palindromes ...... 194 6.9 Case Study: Displaying Prime Numbers...... 195

CHAPTER 7 Introduction to Data Structures and Arrays...... 201 7.1 Introduction to Data Structures...... 202 7.2 Array Basics...... 203 7.3 Case Study: Analyzing Numbers ...... 211 7.4 Case Study: Deck of Cards...... 212 7.5 The Arrays Class...... 214

CHAPTER 8 Using Methods to Modularize Code...... 219 8.1 Introduction ...... 220 8.2 Defining a Method...... 221 8.3 Calling a Method...... 222 8.4 void Method Example...... 225 8.5 Passing Arguments by Values...... 228 8.6 Modularizing Code...... 230 8.7 Case Study: Converting Hexadecimals to Decimals...... 232 8.8 Software Design Strategies Using Abstraction and Stepwise Refinement...... 235 8.9 Evaluating and Documenting the Design...... 243

CHAPTER 9 Introduction to Object-Oriented Programming...... 251 9.1 Introduction ...... 252 9.2 Defining Classes for Objects...... 253 9.3 Example: Defining Classes and Creating Objects...... 255

A01_CP_FM.indd 7 3/29/17 1:11 PM viii Table of Contents

9.4 Constructing Objects Using Constructors...... 261 9.5 Instantiating an Object and Accessing its Members...... 262 9.6 Using Classes from the Java Library...... 263

CHAPTER 10 Identifying Security Risks and Complying with Government Regulations . .269 10.1 Security Risk Assessment...... 270 10.2 Identify Risks to Computer Systems...... 272 10.3 How Encryption Works...... 276 10.4 Recovering from System Failure and Computer Malware ...... 281 10.5 Prevention Strategies...... 283 10.6 Computer Crimes and the Law ...... 285 10.7 Privacy Rights ...... 287 10.8 Understanding Cookies...... 290

SUPPLEMENT A NetBeans Tutorial...... 295

SUPPLEMENT B Eclipse Tutorial...... 303

SUPPLEMENT Using Packages...... 309

SUPPLEMENT Algorithmic Thinking...... 311

SUPPLEMENT E Understanding Variable Scope...... 327

SUPPLEMENT F Nested Loops...... 331

SUPPLEMENT G Multidimensional Arrays ...... 335

A01_CP_FM.indd 8 3/29/17 1:11 PM Table of Contents ix

APPENDIX A Java Keywords...... 369

APPENDIX B The ASCII Character Set...... 371

APPENDIX C Operator Precedence Chart...... 373

APPENDIX D Number Systems ...... 375

APPENDIX E Java Quick Reference...... 381

APPENDIX F Java Modifiers ...... 383

APPENDIX G Special Floating-Point Values...... 385

APPENDIX H Regular Expressions...... 387

APPENDIX I Enumerated Types ...... 393

APPENDIX J Bitwise Operators ...... 399

Glossary...... 401

Index...... 413

A01_CP_FM.indd 9 3/29/17 1:11 PM