You are previewing Programming Like a Pro for Teens.
O'Reilly logo
Programming Like a Pro for Teens

Book Description

Are you ready to learn how to program a computer? You'll do just that in this book. PROGRAMMING LIKE A PRO FOR TEENS is written in a friendly, unassuming voice that makes it possible for you to master the ideas and concepts that professionals use for programming every day. You learn algorithmic thinking and problem-solving in addition to the C++ language. This book takes a different approach than others that teach programming. It focuses on problem-solving techniques and thought processes and introduces features at your level of complexity. Introductory problem-solving techniques pave the way toward increasingly more advanced techniques. This approach allows you to engage in meaningful programming experiences early in the book, which motivates you to continue. Solutions to end-of-chapter exercises, source code, and other learning materials are included on the companion website.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. The Philosophy of this Book
    2. How to Use this Book
    3. How this Book is Organized
    4. Who this Book is for
    5. Companion Website Downloads
  5. 1. Getting Started
    1. The Computer System: Hardware and Software
      1. Hardware
        1. Processing Device
        2. Memory Devices
        3. Storage Devices
        4. Input Devices
        5. Output Devices
      2. Software
    2. What Is a Programming Language?
    3. The Elements of Programming Languages
    4. Software Development Process
      1. A Professional’s Software Development Process
      2. A Beginner’s Software Development Process
        1. Analyze the Problem
        2. Design a Solution
        3. Program the Solution
        4. Test and Debug the Solution
        5. Determine If It Works
    5. Summary
    6. Exercises
  6. 2. The Nature of the Problems and Solutions
    1. Problems, Problems, and More Problems
    2. The Algorithm
      1. Representing Algorithms: Pseudocode
        1. Pseudocode Statements
        2. Pseudocode Examples
      2. Representing Algorithms: Flowcharts
        1. Flowcharts: The Symbols
        2. Flowchart Examples
    3. Creating Solutions
      1. Preparing to Create Solutions
      2. How to Develop an Algorithm
        1. Step 1: Analyze the Problem
        2. Step 2: Write the Algorithm
        3. Step 3: Verify the Algorithm
    4. Summary
    5. Exercises
  7. 3. Introduction to the Core C++ Language
    1. C++ Program Template
    2. Your First C++ Program
    3. How Your Programs Execute
    4. The Core C++ Language
      1. C++ Punctuation
      2. Representing Data
        1. Finding the Variable Names
        2. Declaring the Variable Names
      3. Sequential Statements in C++
        1. Assignment Statements: Translating Arithmetic Set Operations
        2. Assignment Statements: Translating Nonarithmetic Set Operations
        3. Translating Input and Output Pseudocode Statements into C++
          1. Input Statements
          2. Output Statements
      4. Decision-Making Statements in C++
      5. Looping Statements in C++
      6. Translating an Entire Algorithm to C++
      7. Lists in C++
    5. Summary
    6. Exercises
  8. 4. Numerical Problems
    1. Compound Interest
      1. Compound Interest Mathematics
      2. The Algorithm: Compound Interest
      3. The C++ Program: Compound Interest
    2. C++ Feature: Formatted Output
    3. Computing the Square Root
      1. Background: Newton-Raphson
      2. Algorithm: Computing the Square Root
      3. The C++ Program: Computing the Square Root
    4. C++ Feature: Functions
      1. Functions as Tasks
      2. Functions in Pseudocode
      3. Functions in C++
    5. C++ Feature: The Math Library
    6. C++ Feature: Counting Loops
    7. Summary
    8. Exercises
  9. 5. Divide and Conquer
    1. Real-Life Illustrations
    2. Divide and Conquer in Computer Programming
      1. Searching: Looking for Data
        1. Linear Search
        2. Binary Search
        3. An Alternative Implementation
      2. Sorting: Putting Data in Order
    3. Summary
    4. Exercises
  10. 6. Small-Scale Problems
    1. Problem 1: Paper, Scissors, Rock!
      1. Analyze the Problem
      2. Design the Algorithms
      3. Implement in C++
      4. C++: Random Numbers
      5. C++: Character Library
      6. The C++ Program for Paper, Scissors, Rock
    2. Problem 2: Demographic Analysis
      1. Analyze the Problem
      2. Design the Algorithms
      3. The C++ Solution for Demographic Analysis
        1. C++ Feature: switch Statements
        2. C++ Source Code
    3. Summary
    4. Exercises
  11. 7. Top-Down Design
    1. Top-Down Design Principles
    2. Example of Stepwise Refinement
      1. Determine the Names of the Players
      2. Deal Two Cards to Players
        1. Selecting Cards from the Deck
        2. Evaluating Hands
      3. Allow Players to Take More Cards
      4. Evaluate Hands for Winners
    3. Summary
    4. Exercises
  12. 8. Bottom-Up Design
    1. Bottom-Up Design Principles
    2. Bottom-Up Design Example
      1. Card Game Library
      2. Bottom-Up Design of Blackjack
    3. Top-Down Versus Bottom-Up
    4. Summary
    5. Exercises
  13. 9. Medium-Scale Problems
    1. Blackjack Game
    2. Data Representation: Single and Multidimensional Arrays
      1. Parallel Arrays in Other Languages
      2. Parallel Arrays in C++
      3. Introduction to Multidimensional Array Concepts
      4. Multidimensional Arrays in C++
    3. Functions: Pass-By-Reference in C++
    4. The Complete Blackjack Functions in C++
    5. Case Study: Expense Report Program
      1. Introduction to Dynamic Memory Allocation Concepts
      2. Dynamic Memory Allocation in C++
      3. Dynamic Memory Allocation in Expense Report
    6. Records in C++
      1. Defining Records in C++
      2. Using Records in C++
      3. Accessing Fields in C++ Records
    7. Files in C++
      1. File Data Types in C++
      2. File Processing in C++
      3. File Error Handling in C++
    8. Complete Expense Report Program
    9. Summary
    10. Exercises
  14. 10. Introduction to Object-Oriented Design
    1. Overview of OOP
    2. The Principles of OOP
    3. OOP as Simulation
    4. Object-Oriented Design Process
      1. The Blackjack Problem
      2. The OOD Process: Step 1 (Classes)
      3. The OOD Process: Step 2 (Responsibilities)
      4. The OOD Process: Step 3 (Interactions)
    5. Summary
    6. Exercises
  15. 11. Object-Oriented Programming in C++: Part I
    1. Classes as Types
      1. Declaring a Class
      2. Defining Member Functions
      3. Creating and Using Instances of a Class
      4. Accessing Members of the Class
      5. Initializing Data Members of the Class
      6. Deallocating Data Members of the Class
    2. Case Study: Cyber Bank Application
      1. Handling Multiple Source Code Files
      2. Cyber Bank Application Sample Output
      3. Cyber Bank Application Source Code
    3. Case Study: The Fraction Data Type
      1. Example of Using the Fraction Data Type
      2. Operator Overloading in C++
        1. Overloading Using friend Functions
        2. Overloading Binary Arithmetic and Logic Operators
        3. Overloading Assignment Operators
        4. Overloading Input and Output Operators
      3. The Fraction Class Source Code
    4. Summary
    5. Exercises
  16. 12. Object-Oriented Programming in C++: Part II
    1. Pointers to Objects
    2. Accessing Class Members from an Array of Pointers
    3. Case Study: Cyber Bank with Multiuser
      1. Cyber Bank Version 2 in Action
      2. Cyber Bank Version 2 Source Code
    4. Inheritance in C++
      1. Inheritance Examples
      2. Implementing Inheritance in C++
    5. Summary
    6. Exercises
  17. Installing Development Software
    1. Windows: Visual Studio Express 2010
      1. Visit the Website
      2. Download the Installation Package
      3. Install the Software
      4. Open and Test Software
      5. Configure and Register
      6. Use Other Tutorial Resources
    2. Mac OS X: Xcode
      1. Install the Software from the DVD
      2. Open and Test Software
      3. Configure Xcode
      4. Download Xcode Tools (Optional)
      5. Use Other Tutorial Resources