Introduction to Computers, Problem Solving, and Programming Chapter 1.

Slides:



Advertisements
Similar presentations
Chapter 1 An Overview of Computers and Programming Languages.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Overview of Programming and Problem Solving ROBERT REAVES.
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Chapter 1: An Overview of Computers and Programming Languages
Introduction to C++ Programming CS 117 Section 2 and KNET Sections Spring 2001 MWF 1:40-2:30.
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Basics Machine, software, and program design JPC and JWD © 2002 McGraw-Hill, Inc.
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.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
COS120 Software Development Using C++ AUBG Fall semester 2010
CS 115 Chapter 1 Overview of Programming and Problem Solving.
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.
Chapter 1: An Overview of Computers and Programming Languages.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CS 161 INTRO TO PROGRAMMING I Dr. Blaise W. Liffick Fall
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers, Problem Solving, and Programming Problem.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
COS120 Software Development Using C++ AUBG Fall semester 2010 Ref book: Problem Solving, Abstraction and Design Using C++ Authors: Frank Friedman, Elliot.
Chapter 4 Programming Concepts Dept. of Computer Engineering Khon Kaen University.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CISC105 General Computer Science Class 1 – 6/5/2006.
1 Overview of Programming and Problem Solving Chapter 1.
Chapter 1: An Overview of Computers and Programming Languages
Introduction to Computers, Problem Solving, and Programming Chapter 1.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
Brief History of Computers and Computer Languages.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Computer Architecture
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 1: An Overview of Computers and Programming Languages.
Hardware and Software Programming. COMP104 Lecture 2 / Slide 2 Hardware and Software l Why should we bother with hardware, while we are having a programming.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1 An Overview of Computers and Programming Languages.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Chapter 1 Background Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
By Kundang K Juman Hardware & Software. COMP102 Prog. Fundamentals I: Software / Slide 2 l Four components of a computer system: n CPU - central processing.
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.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
Professor John CarelliKutztown University Computer Science Department Computer Science I CSC 135.
Chapter 1: Introduction to Computers, Problem Solving, and Programming
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1 – Introduction to Computers, the Internet, and the Web
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
UNIV 103 CS Majors Seminar Dr. Blaise W. Liffick Fall 2017.
Computer Science I CSC 135.
Programming Logic and Design Eighth Edition
Presentation transcript:

Introduction to Computers, Problem Solving, and Programming Chapter 1

2 t Computer - “A device for counting or computing” t Dr. John Atanasoff - 1st computer (1930). t ENIAC 1946 at U of Penn (30 Tons, 30-by-50 foot space, data in memory, programmed by connecting switches and wires) t Dr. John Von Neumann - Princeton –Stored program concept –Memory rather than wires and switches. t Evolution –1970s: Apple microcomputers –Minicomputers –Mainframes (time-sharing systems) –Supercomputers: for very computing-intensive tasks –Personal computers/Workstations –Laptops 1.1 Overview of Computers

3 t Von Neumann architecture basis for today's computers t VLSI Technology made computers affordable, small and available to the public t How programming has changed over time Overview of Computers

4 t Every computer is organized roughly into six parts –CPU - central processing unit Where decisions are made, computations are performed, and input/output requests are delegated –Main Memory Stores information being processed by the CPU –Secondary Memory Stores data and programs 1.2 Computer Hardware

5 –Input devices Allows people to supply information to computers –Output devices Allows people to receive information from computers –Network connection Modems / Ethernet interface Computer Hardware

6 Computer Components

7 Main Memory l 354 l l Address l Contents

8 Main Memory t Stores –programs –data –results t Types –RAM –ROM

9 Secondary Memory & Storage t Semi permanent data-storage capability –Tape or Disk –Hard disk –CD ROM t Secondary memory has much more storage capacity

10 CPU t “Brains” of the computer –Arithmetic calculations are performed using the Arithmetic/Logical Unit or ALU –Control unit decodes and executes instructions t Arithmetic operations are performed using binary number system

11 CPU t Fundamental building block is a switch –Switches are made from ultrasmall transistors t Examples –The Pentium ® processor contains about three million transistors –The Pentium Pro ® has about 5.5 million transistors

12 Input / Output Devices t Accessories that allow computer to perform specific tasks –Receiving information for processing –Return the results of processing –Store information t Common input and output devices –PrinterJoystickCD-ROM –KeyboardMonitor

13 Computer Networks t LAN - Local area network –Organizational t WAN - Wide area network –Internet

14 World Wide Web t Introduced 1989 t Developed by CERN –European Laboratory for Particle Physics t Web browser –GUI –Netscape –IE

15 t Application software –Programs designed to perform specific tasks that are transparent to the user t System software –Programs that support the execution and development of other programs –Two major types Operating systems Translation systems 1.3 Computer Software

16 Application Software t Application software is the software that has made using computers indispensable and popular t Common application software –Word processors –Desktop publishing programs –Spreadsheets –Presentation managers –Drawing programs

17 t Controls and manages the computing resources t Important services that an operating system provides –File system –Commands that allow for manipulation of the file system –Ability to perform input and output on a variety of devices –Management of the running systems t Examples –MSDOS ®, Windows ®, Unix ® Operating System

18 Programming Languages t Machine Language –“Native tongue” of the computer –Binary 0s and 1s that specify what to do t Assembly language –Mnemonic code t High - Level Languages –Resemble human language (C++, C, Pascal) cost = price + tax;

19 Programming Languages t Language Standard –Syntax (grammatical form) (=> rules) –Portability programs ideally need no modification when moved from one machine to another t Source Program t Object Program t Executable Program

20 Object Oriented Programming t OOP derived from C t Bjarne Stroustrup (AT&T) t Since mid-1980s, standard 1998 t Popular a.o. because of: –Reuse of Classes and objects –Efficiency t Class –Definition of attributes and methods of an object t Method –An operation that uses the object data

21 OO Programming and Structured Programming t Object –An instance of a class that has all the attributes and methods included in the class definition t C++ is organized in a hierarchy –Super Classes (“Father Classes”) It includes some of attributes and methods of a subclass –Sub Classes (Son Classes) It is derived from a super class and it may contain own attributes and methods t Object-oriented design and programming supports good software engineering –Algorithms operate on well-defined data

22 OO Programming and Structured Programming t Object-oriented design promotes thinking about software in a way that models the real world –Objects may model real things t Algorithms are the basis for the procedural sections (Structured Programs) –Highly structured –Top-down design –Step-wise refinement t Procedural languages (e.g. C, Pascal, Fortran): –No clear relationship between algorithms and data –OO tries to fill this gap

23 Object Oriented Design t Abstraction (Different views on the same object!) –Extract the relevant properties of an object while ignoring inessential details –Ignore irrelevant properties t Encapsulation (Access only through interfaces!) –Breaking down an object into parts, hiding and protecting its essential information, and supplying an interface to modify the information in a controlled and useful manner

24 Object Oriented Design t Modularity –Dividing an object into smaller pieces or modules such that the object is easier to understand and manipulate –E.g. “Consists–of” relationship! t Hierarchy –Ranking or ordering of objects based on some relationship between them –E.g. “Is-A” relationship!

25 t Process of extracting only the relevant properties of an object t Extracted properties define a view of the object t Different contexts may have different views or abstractions Abstraction

26 t Examples: –Car dealer views a car from selling features standpoint Price, warranty, color, etc. –Mechanic views a car from systems maintenance standpoint Oil, oil filter, spark plugs, etc. –Abstraction depends on the context Abstraction

27 Encapsulation t Breaking down an object into parts, hiding and protecting its essential information, and supplying an interface to modify the information in a controlled and useful manner t By hiding the information its representation and content can be changed without affecting other parts of the system

28 Encapsulation t Example - car radio –Controlled by switches and buttons –The details of how it works is hidden –No manipulation of the car radio is allowed except using the provided switches and buttons –  Encapsulation restricts the use to interfaces

29 Modularity t Dividing an object so that the object holds useful information and it is easier to understand t Most complex systems are modular –Cooling System –Ignition System –Fuel System

30 Modularity t Example - Automobile can be decomposed into subsystems –Cooling system Radiator Thermostat Water pump –Ignition system Battery Starter Spark plugs

31 Hierarchy t Ranking or ordering of objects based on some relationship between them t Hierarchies facilitate understanding complex organizations and systems –Example - a company hierarchy helps employees understand the structure of their company and their positions

32 Hierarchy t Example: Means of transportation TrainCar BMWVW - Color - Year - Type - # Wagons - # Doors - Fuel type

33 OO Classes t Later we will use data abstractions –C++ language t Will apply OO techniques –Structured Programming –Object Oriented Programming t Model our own objects or abstractions

Processing a High-Level Language Program t Set of programs used to develop software t A key component is a translator t Types of translators –Compiler –Linker t Examples –g++, Borland C++ ®, Microsoft Visual C++ ®

35 Processing a Program t Editor used to enter the program –Source program (file.cpp) –UNIX vi text editor t Compiler translates the source program –Displays syntax errors (not descriptive) t Linker/Loader to combine object file with other object files –Executable program

36 Processing a Program t Major activities –Editing –Compiling –Linking with pre-compiled files Object files Library modules –Loading and executing –Viewing the behavior of the program

37 Process Cycle

Software Development Method t Steps for any Software development process –1. Specify the problem requirement –2. Analyze the problem –3. Design an algorithm for solving the problem –4. Implement the algorithm –5. Test and verify the program –6. Maintain and update the program

39 Software Development Method t Problem requirement –What is the problem exactly? –Eliminate irrelevant aspects –Clear and unambiguous problem statement –Needs interaction with the person who posed the problem t Problem Analysis - (Correct Problem) –Identify data objects –Determine Input / Output data –Identify constraints on the problem/solution t These two steps are very important for avoiding to solve the wrong problem

40 Software Development Method t Example –Problem: Compute and display the total cost of apples given the number of pounds of apples and the cost per pound of apples –Analysis: Inputs: –Quantity of apples in pounds –Cost per pound Output: –Total costs (in dollars) Main formula: –Total cost = Cost per pound * Pounds of apples

41 Software Development Method t Design –Problem solving step –Decompose into smaller problems –Top-down design (divide and conquer) –Develop Algorithm Algorithm: List of steps to solve a problem Algorithm refinement: Developing a sub-algorithm for a particular step in the main algorithm –Desk check Simulate the algorithm execution for simple interesting cases using pencil and paper

42 Software Development Method t Implementation –Writing the algorithm in a special programming language e.g. C++ –Requires understanding the algorithmic notation as well as the details of the respective programming language t Testing –Verify that the program meets its requirements –Unit test (only one sub-problem) –System test (whole problem) –Test coverage! t Documentation –Key part in the development process –Accompanying activity in each phase

43 Software Development Method t Maintenance: –Modify a program to remove errors –Modify a program in order to extend it –Initial programmer is very often not the person who does maintenance! –Understandability of code, use of guidelines t Failure is a part of the process –The step-by-step development help avoid failures –But there are no guaranties –Importance of documentation

44 Software Development Method t Software engineering –Area of computer science concerned with: Building large software systems Providing solutions for efficient and effective software development t Challenge –Tremendous advances in hardware have not been accompanied by comparable advances in software –=> Software crisis

45 Software Engineering Goals t Reliability –An unreliable life-critical system can be fatal –Software is in general more expensive and less reliable than hardware –E.g. Year 2000 problem –Maintenance affects availability t Understandability –Future development becomes very difficult if software is hard to understand t Cost Effectiveness –Cost to develop and maintain should not exceed profit

46 Software Engineering Goals t Adaptability –Ease of modification in the program or in its environment –System that is adaptive is easier to alter and expand t Reusability –Reduces development costs –Improves reliability and maintainability –(Exception: Reuse of unreliable software)

Applying the Software Development Method t Case Study:Converting Miles to Kilometers –Problem Your summer surveying job requires you to study some maps that give distances in kilometers and some that use miles. You and your coworkers prefer to deal in metric measurements. Write a program that performs the necessary conversion.

48 Applying the Software Development Method –Analysis The first step in solving this problem is to determine what you are asked to do. You must convert from one system of measurement to another, but are you supposed to convert from kilometers to miles, or vice versa? The problem states that you prefer to deal in metric measurements, so you must convert distance measurements in miles to kilometers.

49 Applying the Software Development Method –Design The next step is to formulate the algorithm that solves the problem. Begin by listing the three major steps, or sub problems, of the algorithm. 1. Get distance in miles 2. Convert to kilometers 3. Display distance in kilometers Refinement of step 2: The distance in kilometers is times the distance in miles Desk check 10 miles * = km (this would be displayed) –Implementation To implement the solution, you must write the algorithm as a C++ program. –Testing How do you know the sample run is correct?

50 Applying the Software Development Method t C++ code: #include Using namespace std< int main() { const Km_Per_Mile = 1.609; float miles, kms; // Get distance in miles cout << “Enter distance in miles: ”; cin >> miles; // convert to kilometers kms = Km_Per_Mile * miles; // display distance in kilometers cout << “The distance in kms is “ << kms << endl; return 0; }

Professional Ethics for Computer Programmers t Privacy and Misuse of Data –Falsifying data in a database –Computer thefts t Computer Hacking –Breaking secure systems e.g. for amusement –Spreading viruses in a network t Plagiarism and Software Piracy –Using foreign programs without permission –Violating copyright agreements t Misuse of a Computer Resource –Illegal sharing of accounts and passwords in order to access special systems and databases

Summary t History –1930 first computer –Eniac: programmed by hand –Von-Neumann: stored program concept t Components of computers –CPU (Central processing unit) Control Unit Arithmetic and Logic Unit (ALU) –Main Memory Addresses Data: Bytes, Bits, Words

Summary –Secondary storage (unit is file) Disks Tapes Floppy CDs Removable disks –I/O devices Keyboard (i) Monitor (o) Printer (o) Modem (i/o)

Summary t Computer networks –LAN –WAN –WWW t Software –Operating system –Compilers –Application software

Summary t Programming Languages –High level language (e.g. procedural, oo, logic, functional) –Assembly language –Machine language t Tools for program development –Editor –Compiler –Linker –Loader

Summary t Basic concepts of OO programming –Class –Object –Method –Abstraction –Encapsulation –Modularity –Hierarchy

Summary t Basic steps of software development –Specification of the problem –Analysis –Design –Implementation –Test –Maintenance t Failures ! t Software Engineering Goals (e.g. reliability, cost effectiveness, reusability) t Ethics in the use of computers