An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Chapter 1 An Overview of Computers and Logic
CIS105 Chapter 1 Theory Review. Page 2 Hardware and Software are the two major components o any computer system Hardware is the set of physical devices.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Chapter 1: An Overview of Computers and Programming Languages
An Overview of Computers and Logic
An Overview of Programming Logic and Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Programming Logic and Design Fourth Edition, Introductory
An Overview of Computers and Programming
Computers & Logic An Overview. Hardware Hardware is the equipment, or the devices, associated with a computer. For a computer to be useful, however, it.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
CS102 Introduction to Computer Programming
 2003 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers, the Internet, and the Web Outline 1.1 Introduction 1.2 What Is a.
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Programming Logic and Design Fifth Edition, Comprehensive
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Chapter 1 An Overview of Computers and Programming Languages.
An Overview of Computers and Logic
1 CSC103: Introduction to Computer and Programming Lecture No 2.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Logic and Systems A beginner’s guide.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Mrs. Ulshafer August, 2013 Java Programming Chapter 1.
What is a computer? Computer is a device for processing information.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Programming Logic and Design Seventh Edition
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Chapter 1 An Overview of Computers and Programming Languages.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CHAPTER 1 OVERVIEW OF COMPUTER AND PROGRAMMING 1.1 Electronic Computer Then and Now 1.2 Computer Hardware 1.3 Computer Software 1.4 The Software Development.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming
BASIC PROGRAMMING C SCP1103 (02)
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
BASIC PROGRAMMING C SCP1103 (02)
DDC 1023 – Programming Technique
Chapter 1. Introduction to Computers and Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
Chapter 1: Introduction to Computers and Programming
Topics Introduction Hardware and Software How Computers Store Data
Programming Logic and Design Eighth Edition
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic

An Object-Oriented Approach to Programming Logic and Design 2 Objectives Understand computer components Understand the evolution of programming techniques Describe the steps involved in the programming process Understand flowcharts and pseudocode statements

An Object-Oriented Approach to Programming Logic and Design 3 Objectives (continued) Create an application class with a main() method Use and name variables Assign values to variables Describe data types

An Object-Oriented Approach to Programming Logic and Design 4 Understanding Computer Components and Operations Two major components of any computer system: –Hardware: equipment or devices associated with the computer –Software: programs, or sets of instructions, written by programmers Application software – applied to a task, such as word processing, spreadsheets, payroll, etc. System software – manage computer resources

An Object-Oriented Approach to Programming Logic and Design 5 Understanding Computer Components and Operations (continued) Together, hardware and software accomplish four major operations: –Input –Processing –Output –Storage

An Object-Oriented Approach to Programming Logic and Design 6 Understanding Computer Components and Operations (continued) Input: a means for data to enter the computer through an input device such as: –Mouse –Keyboard –Scanner

An Object-Oriented Approach to Programming Logic and Design 7 Understanding Computer Components and Operations (continued) Processing: performing mathematical or other operations on the data –Takes place in the central processing unit (CPU) using machine instructions –Software provides machine instructions to the CPU –Software is written using programming languages

An Object-Oriented Approach to Programming Logic and Design 8 Understanding Computer Components and Operations (continued) Output: a means for data to be viewed, printed, interpreted, or stored, using devices such as: –Printer –Monitor –Speakers

An Object-Oriented Approach to Programming Logic and Design 9 Understanding Computer Components and Operations (continued) Storage: maintaining the data in internal or external storage devices Internal storage: main memory, which is volatile (lost when the power is turned off) External storage: permanent storage outside of main memory in devices such as –Disk drives: hard and floppy –USB memory drives –Magnetic tapes and cartridges –Compact discs (CD-ROMs) and digital video discs (DVDs)

An Object-Oriented Approach to Programming Logic and Design 10 Understanding Computer Components and Operations (continued) Programming languages: used to create machine instructions in a language that humans can understand –Common languages include Visual Basic, C#. C++, COBOL, RPG, Fortran, Java, etc. –Programming languages have rules governing the usage and punctuation, called the syntax –Programming language instructions are translated to machine instructions using a compiler or interpreter

An Object-Oriented Approach to Programming Logic and Design 11 Understanding Computer Components and Operations (continued) Two kinds of programming language errors: –Syntax errors: incorrect spelling or incorrect structure of the language elements –Semantic (logic) errors: incorrect instructions or incorrect order of instructions When the program has been written and compiled, it must then be executed or run

An Object-Oriented Approach to Programming Logic and Design 12 Understanding Computer Components and Operations (continued) Example of a logic error in instructions for making a cake: Stir Add two eggs Add a gallon of gasoline Bake at 350 degrees for 45 minutes Add three cups of flour

An Object-Oriented Approach to Programming Logic and Design 13 Understanding the Evolution of Programming Techniques: Languages Computer programming began in the 1940s, using machine instructions and codes for memory addresses Newer languages look more like natural languages, using variables to represent memory addresses

An Object-Oriented Approach to Programming Logic and Design 14 Understanding the Evolution of Programming Techniques: Structure Older programs were written as one component, from start to finish Newer programs are written as separate, self- contained, reusable components that are combined together

An Object-Oriented Approach to Programming Logic and Design 15 Understanding the Evolution of Programming Techniques: Techniques Two major techniques for developing programs: –Procedural programming: focuses on creating procedures and steps for accomplishing subtasks –Object-Oriented programming (OOP): focuses on objects, their attributes, behaviors, and states Attributes: features of an object Behaviors: what the object does States: the set of values of all of the attributes

An Object-Oriented Approach to Programming Logic and Design 16 Understanding the Programming Process Object-oriented approach to developing a computer software system involves three tasks: –Object-oriented analysis (OOA): analyzing the system –Object-oriented design (OOD): designing the system –Object-oriented programming (OOP): writing the programs Our focus is on writing programs that are already designed

An Object-Oriented Approach to Programming Logic and Design 17 Understanding the Programming Process (continued) Steps in writing programs: 1.Envision and create the objects that are required, and identify how they relate to each other (data modeling) 2.Create the classes (the code to create a general category, or template, for an object including its attributes and behaviors) 3.Code the statements in the program to manipulate the objects

An Object-Oriented Approach to Programming Logic and Design 18 Understanding the Programming Process (continued) Steps in writing programs (continued): 4.Compile the program to obtain machine instructions 5.Test the program 6.Put the program into production

An Object-Oriented Approach to Programming Logic and Design 19 Understanding the Programming Process (continued)

An Object-Oriented Approach to Programming Logic and Design 20 Using Flowcharts and Pseudocode Statements Flowchart: a pictorial representation of the logical steps of the program –Program steps are in boxes, connected with flowlines (arrows) to show the order of processing Pseudocode: an English-like representation of the logical steps of the program; looks like a programming language, but isn’t

An Object-Oriented Approach to Programming Logic and Design 21 Using Flowcharts and Pseudocode Statements (continued) Example: Flowchart

An Object-Oriented Approach to Programming Logic and Design 22 Creating an Application Class with a main() Method In “pure view,” every application is a class Pseudocode for an application begins with the word class and end with endClass Method: a set of statements that performs some task or group of tasks If a class contains only one method that executes, the method is named main()

An Object-Oriented Approach to Programming Logic and Design 23 Creating an Application Class with a main() Method (continued) Identifier: the name of a programming object such as a class, method, or variable –Specific programming languages have rules for the structure of identifiers Our rules for pseudocode are: –Identifier names must be one word, with letters, digits, hyphens, underscores, but no spaces –Identifiers should have an appropriate meaning –Compound words such as HelloClass are OK

An Object-Oriented Approach to Programming Logic and Design 24 Creating an Application Class with a main() Method (continued) The statement main() is the method header A class that contains a main() method is an executable program Every method ends with a return statement. Place the action statements of the main() method between the main() method header and the return statement

An Object-Oriented Approach to Programming Logic and Design 25 Creating an Application Class with a main() Method (continued)

An Object-Oriented Approach to Programming Logic and Design 26 Creating an Application Class with a main() Method (continued)

An Object-Oriented Approach to Programming Logic and Design 27 Creating an Application Class with a main() Method (continued)

An Object-Oriented Approach to Programming Logic and Design 28 Using and Naming Variables Variables or fields are memory locations whose contents can change over time Most of the objects in programs contain variables that hold the objects’ attributes Use the same rules for naming variables as for naming classes

An Object-Oriented Approach to Programming Logic and Design 29 Using and Naming Variables (continued)

An Object-Oriented Approach to Programming Logic and Design 30 Assigning Values to Variables Assignment statements: assign values to variables calculatedAnswer = inputNumber * 2 Assignment operator: requires the name of a memory location on its left side where the result will be stored Named constant: a named memory location, similar to a variable, whose value never changes during program execution

An Object-Oriented Approach to Programming Logic and Design 31 Understanding Data Types Two basic types of data—text and numeric Numbers: written as digits with no quotation marks; used for numeric calculations. Ex: 42 String constant: a specific set of characters enclosed in quotations. Ex: “Chris” Character variables: variables that hold a single character String variables: variables that hold a group of characters

An Object-Oriented Approach to Programming Logic and Design 32 Understanding Data Types (continued) Variable declaration statement: contains the data type and the identifier Initializing a variable: setting an initial starting value for the variable Types of numeric data (depending on the programming language) may include integer, floating point, and other types Default values – automatic values for uninitialized variables

An Object-Oriented Approach to Programming Logic and Design 33 Understanding Data Types (continued) Example: Declare the variable, and set the value afterwards

An Object-Oriented Approach to Programming Logic and Design 34 Understanding Data Types (continued) Example: Initialize the variable when declaring it

An Object-Oriented Approach to Programming Logic and Design 35 Understanding Data Types (continued) Example: DoubleNumber class allows the user to enter a number and see the result when the value is doubled.

An Object-Oriented Approach to Programming Logic and Design 36 Summary Hardware and software accomplish four major operations: Input, Processing, Output, and Storage Computer programming languages are used to write machine instructions Object-oriented programming, or OOP, focuses on objects and describes their features, or attributes, and their behaviors

An Object-Oriented Approach to Programming Logic and Design 37 Summary (continued) A programmer must identify objects and classes, code the program, translate it into machine language, test it, and put it into production Flowcharts and/or pseudocode are used to plan the logic for a programming solution Variables are named memory locations whose contents can vary –Choose meaningful names for your variables

An Object-Oriented Approach to Programming Logic and Design 38 Summary (continued) Assignment always takes place from right to left Variable declaration tells the computer what type of data to expect Numeric, character, and string variables are handled differently by the computer