computer hardware and software 1.1 what is a computer? 1.2 computer organization

35
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 1 – Car Payment Calculator and Guess the Number Application: Introducing Computers, the Internet and C++ Programming Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization 1.4 Computer Languages and Levels 1.9 Key Software Trend: Object Technology Computer Languages and IDEs 1.7 Early Procedural High-Level Languages 1.5 C and C++ 1.6 Java Python Integrated Development Environment (IDE) 1.8 Microsoft .NET Framework Tutorial 1.10 Compiling and Running C++ Applications 1.11 Test-Driving the Applications 1.12 Internet and Web Resources Lab and Homework Assignment

Upload: kapono

Post on 04-Feb-2016

73 views

Category:

Documents


1 download

DESCRIPTION

Tutorial 1 – Car Payment Calculator and Guess the Number Application: Introducing Computers, the Internet and C++ Programming. Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization 1.4 Computer Languages and Levels 1.9 Key Software Trend: Object Technology - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

Tutorial 1 – Car Payment Calculator and Guess the Number Application: Introducing Computers, the Internet and C++ Programming

Computer Hardware and Software1.1 What Is a Computer?1.2 Computer Organization1.4 Computer Languages and Levels1.9 Key Software Trend: Object TechnologyComputer Languages and IDEs1.7 Early Procedural High-Level Languages1.5 C and C++1.6 Java

PythonIntegrated Development Environment (IDE)

1.8 Microsoft .NET FrameworkTutorial1.10 Compiling and Running C++ Applications1.11 Test-Driving the Applications1.12 Internet and Web ResourcesLab and Homework Assignment

Page 2: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

Objectives

• In this tutorial, you will learn to:– Identify the characteristics of programming languages.

– Apply the basics of object-oriented programming.

– Run your first C++ application.

– Locate additional C++ information using the Internet.

Page 3: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.1 What Is a Computer?

• Computers are designed to meet a specific set of requirements.

• Computer History

• In the early days, these requirements were to meet some military, science, civil, or commercial need.

– For the military, it was predominately the calculation of ballistic tables.

– For science to calculate the motion of the planets or the weather.

– For civil keeping track of people and commercial keeping track of the money.

• To meet these requirements the computer was conceived and described by its hardware and it instruction set.

– Hardware components for all modern day computers, were codified by Von Neumann in his landmark paper describing the architecture of the EDVAC computer

– the instruction set is a list of all the instructions the computer can understand – The Language of the Machine

Page 4: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.2 Computer Organization

• Five (not Six) basic components of a computer– Input

• Obtains information from various input devices such as keyboard or mouse

– Output• Places computer-processed information on output devices (making

it available for use outside of the computer)

– Memory• Usually volatile (data is lost after computer shuts off

Page 5: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.2 Computer Organization (Cont.)

– Arithmetic Logic Unit (ALU)• Performs arithmetic calculations and determines logic

– Control• Oversees all computer activities

• Memory Hierarchy (author’s sixth) – The Pyramid

– Secondary Storage Unit• Nonvolatile (data is retained after computer shuts off)

• Long term

Page 6: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.2 Memory Hierarchy (author’s sixth)

Page 7: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.2 Memory Hierarchy (author’s sixth)

Page 8: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.2 Memory Hierarchy (Cont.)

Page 9: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.4 Computer Languages and Levels

• Machine Languages − The language of the computer

– Example: grossPay = basePay + overtimePay

9100 0100

9110 0102

0f01

9300 0101– The numbers in the above example are in base 16 (hexadecimal)

– Number Systems

• Assembly Languages (ex. AVR, 80x86, ARM, MIPS, Itanium,…)

– Machine language in a human readable form using mnemonics

– Assemblers convert assembly languages to machine languages

lds r16, basePay

lds r17, overtimePay

add r16, r17

sts grossPay, r16

Page 10: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.4 Computer Languages and Levels (Cont.)

• High-Level Languages (ex. Basic, Fortran, COBOL, Ada, Pascal)

– Compilers convert to machine languages

– Linkers package machine language files

– Example:

grossPay = basePay + overtimePay;

• Interpretive Language (ex. Java, Flash, .NET)

– Look and Function just like a High-Level Language.

– Compilers convert to machine independent “intermediate” language

– Interpreters run high-level/intermediate programs directly

• Mid-Level Language (C and C++)

– Combines the elements of high-level languages with the functionality of assembly language and has occasionally been referred to as a middle-level computer language.

Page 11: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.9 Key Software Trend: Object Technology

• Procedural Programming Languages (verb)

– Focus on actions. Good analogy is a Cooking Recipes.

• Objects (noun)

– Object Circle

– Properties – the attributes of an object (adjective).

– Methods – what the object can do (adverb). May also be referred to as behaviors or functions.

– Class

• An object is an instance of a class definition.

• Example: A basketball is an instance of a ball.

Page 12: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.7 Early Procedural High-Level Languages

• BASIC– Beginner’s All-Purpose Symbolic Instruction Code (BASIC)

– For simple programs and teaching novices

• Fortran (FORmula TRANslator)– Developed by IBM

– Still used in engineering community

• COBOL– Still used in business software

– A very Verbose Language

• Pascal– Designed for teaching structured programming (a precursor to Objects)

• Ada– Sponsored by the Department of Defense

– Named after Lady Ada Lovelace (the first computer programmer)

Page 13: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.5 C and C++• C is a middle-level computer language, combining the elements of high-level languages

with the functionality of assembly language

• C is portable, not tied to any particular hardware or operating system.

• The C programming language was developed at Bell Labs circa 1969 – 1973 as a system implementation language for the nascent Unix operating system.

• C was a direct descendant of the language B. The language B was developed by Ken Thompson in 1970 for the new UNIX OS.

• B was a descendant of the language BCPL designed by Martin Richards, a Cambridge University student visiting MIT.

Sources:

• http://www.hitmill.com/programming/cpp/cppHistory.html

• http://cm.bell-labs.com/cm/cs/who/dmr/chist.html

Page 14: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.5 C and C++

• C++ was written by  Bjarne Stroustrup  at Bell Labs during 1983-1985.

• C++ is an extension of C.  Prior to 1983, Bjarne Stroustrup added features to C and formed what he called "C with Classes". He had combined the Simula's use of classes and object-oriented features with the power and efficiency of C.

• The term C++ was first used in 1983.

• Hybrid language

– C style

– Provides capabilities for Object-Oriented Programs (OOPs)

Page 15: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.5 C and C++ (Cont.)

• C++ is a vast language that has evolved over many years.

• C++ is a mainstream language used in industry, engineering, and education.

• C++ is a lean language in that you add to it libraries that your particular program(s) require and exclude overhead libraries that are not needed.

• The hope is to create reusable code and minimize redundancy...this is the notion of OOP or Object Orientated Programming.

Page 16: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.6 Java

• Java and Python are general-purpose interpreted, object-oriented, high-level programming languages

• Java was developed by James Gosling at Sun Microsystems and released in 1995.

• The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities.

• Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture.

• It is intended to let application developers "write once, run anywhere".

• Java is currently one of the most popular programming languages in use, and is widely used from application software to web applications.

Source: http://en.wikipedia.org/wiki/Java_%28programming_language%29

Page 17: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

Python

• Like Java, Python is a general-purpose interpreted, object-oriented, high-level programming language.

• Work on Python started in December 1989 by Guido van Rossum in the Netherlands as a successor to the ABC programming language

• C provided some of Python's syntax,

• One of the early objectives of Python was to be easily learnable and not too arcane in its syntax and semantics, reaching out to non-programmers − this is no longer an active concern.

Source: http://en.wikipedia.org/wiki/History_of_Python

Page 18: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

Integrated Development Environment (IDE) also known as integrated design environment or integrated

debugging environment

• An IDE is a software application that provides comprehensive facilities to computer programmers for software development.

• An IDE normally consists of:

– a source code editor

– a compiler and/or an interpreter

– build automation tools

– a debugger

• Typically an IDE is dedicated to a specific programming language, providing a feature set for the programming paradigms of the language.

• Some multiple-language IDEs are in use, such as Eclipse, NetBeans, and Microsoft Visual Studio to name a few.

Page 19: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.8 Microsoft .NET Framework

• The Microsoft .NET Framework is a software framework for Microsoft Windows operating systems.

• The .NET Framework supports several programming languages (Visual Basic, C++, C#) which allows language interoperability (each language can use code written in other languages).

• All .NET programs are by definition high-level running on an application virtual machine, so that programmers need not consider the capabilities of the specific CPU (Platform independent).

• The .NET Framework includes a large library

– The library provides user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications.

– The class library is used by programmers, who combine it with their own code to produce applications.

– The .NET library is available to all the programming languages that .NET supports.

Page 20: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.10 Compiling and Running C++ Applications

• Files

– Source code files (.cpp)

– Header files (.h)

– Executable files (.exe)

• Compilation

– Turns high-level source code into machine language code

• Command prompt

– Allows text instructions to be given to the computer

Page 21: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

How To Open Dos Prompt Command in Windows 7

• What is it?• It’s a right-click context menu that opens a command

prompt window at the current working directory, wherever you pop up the context menu.

• How?• In Windows Explorer, simply hold the Shift key and

right-click the folder you want to set as working directory, choose Open Command Window here.

Source: http://www.windows7hacker.com/index.php/2009/08/how-to-open-dos-prompt-

command-here-in-windows-7-and-more/

Page 22: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.10 Compiling and Running C++ Applications (Cont.)

Figure 1.1 Command Prompt window in Windows 2000.

Beginning directory for Windows 2000

Page 23: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.10 Compiling and Running C++ Applications (Cont.)

Figure 1.2 Command Prompt window in Windows XP.

Beginning directory for Windows XP

Page 24: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications

• Open Command Prompt– Start > All Programs > Accessories > Command

Prompt• Change directories

– Type cd C:\Examples\Tutorial01\CarPayment– Type cd C:\Examples\Tutorial01\GuessNumber

• Run an application

– Type CarPayment– Type GuessNumber

Page 25: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.3 Changing to the Car Payment Calculator application’s directory.

Note that the current directory changed

Page 26: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.4 Running the Car Payment Calculator application.

Executing the CarPayment application

Page 27: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.5 Car Payment Calculator with data entered.

Page 28: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.6 Car Payment Calculator application displaying calculation results.

Results displayed in tabular format

Close box

Page 29: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.7 Changing to the Guess the Number application’s directory.

Note that the current directory changed

Page 30: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.8 Running the Guess the Number application.

Executing the GuessNumber application

Page 31: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.9 Entering an initial guess.

Page 32: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number

Applications (Cont.)Figure 1.10 Entering a second guess and receiving feedback.

Application displays whether your guess is too high or too low

Page 33: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.11 Test-Driving the Car Payment Calculator and Guess the Number Applications (Cont.)

Figure 1.11 Guessing the correct number.

Entering additional guesses

Entering the correct guess

Page 34: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

1.12 Internet and Web Resources

• www.deitel.com• www.prenhall.com/deitel• www.softlord.com/comp• www.elsop.com/wrc/h_comput.htm• www.w3.org/History.html• www.netvalley.com/intval.html• www.ansi.org• www.cuj.com

Page 35: Computer Hardware and Software 1.1 What Is a Computer? 1.2 Computer Organization

© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

Lab and Homework Assignment• Buy the Textbook.

• Copy example from SimplyCpp CD to your local hard drive (See preface starting on page xxv).

• Download and Install Visual Studio 2010 Express

• Run the Car Payment Calculator and Guess the Number Applications.

• Do Tutorial 1 − Car Payment Calculator and Guess the Number Application.

• Answer and Turn-in Tutorial 1 Questions at the end of the Chapter. Always write the question followed by the answer. Remember to highlight the answer.

• Search the Web for a Good “Hello World” Tutorial using the Microsoft Visual Studio IDE. Include as question 1.16. For the answer write the URL and in a few sentences why you like the tutorial. Web Tutorial may be a website or a video.

• Due next Wednesday