Overview of the computer
This presentation is the property of its rightful owner.
Sponsored Links
1 / 33

Overview of the Computer PowerPoint PPT Presentation


  • 95 Views
  • Uploaded on
  • Presentation posted in: General

Overview of the Computer. Definition : a programmable device that can store, retrieve, and process data. Hardware = physical components of a computer Software = computer programs (the set of all programs available on a computer). application software and system software.

Download Presentation

Overview of the Computer

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Overview of the computer

Overview of the Computer

  • Definition: a programmable device that can store, retrieve, and process data.

  • Hardware = physical components of a computer

  • Software = computer programs (the set of all programs available on a computer).

    • application software and system software.

cosc236/intro


Overview of the computer

Computer components:

cosc236/intro


Programming language

Programming Language

  • Definition: languages with strict grammar rules, symbols, and special words used to construct a computer program

cosc236/intro


Machine language

Machine language

  • the language that can be directly used and understood by the computer

  • operations are very low-level, specific to the architecture (not portable)

  • made up of binary-coded instructions (strings of 0s and 1s)

  • exa: 110011 - add instruction

cosc236/intro


Assembly language

Assembly Language

  • A low-level programming language in which a mnemonic is used to represent each of the machine language instructions for a particular computer

  • Requires assembler

cosc236/intro


Overview of the computer

COMP$PAYPROC PUBLIC

;

;COMP$PAY - procedure to compute gross pay

;(PAY = HOURS * RATE)

MOVAX,HOURS; multiplicand

MULRATE+2; X second word of multiplier

MOVPAY+2,AX; store the product in PAY

;

MOVAX,HOURS; multiplicand

MULRATE; times first word of multiplier

ADDPAY+2,AX; add the product to PAY

ADDPAY,DX; add the carry, if any

RET; end procedure

cosc236/intro


High level languages

High-level languages

  • Basic, C++, Pascal, Java, Ada, Modula-2, Cobol, Fortran…

  • Similar to natural language (easier to use and debug)

  • standardized description of the language exists

cosc236/intro


High level languages cont d

High-level languages cont’d

  • Not understood directly by a computer, must be converted to machine language:

    • Compilers: whole program is translated into another language (machine language or bytecode) and then executed

    • Interpreters: program is translated and executed one line at a time

  • portable (machine-independent)

    • Program is written for any platform

    • compiler translates to each platform

cosc236/intro


Overview of the computer

  • C++ compiled to machine language

    • Requires translating to many different machine languages

  • Java compiled to Java bytecodes

    • One set of bytecodes can execute on many different machines

    • intermediate level

    • machine language for theoretical computer: Java Virtual Machine (JVM)

cosc236/intro


Overview of the computer

Java

  • Class

    • Unit of code that is the basic building block of Java programs

  • Java runtime

    • JRE

    • Executes compiled Java class files

    • Most computers have Java runtimes on their computer

cosc236/intro


Background

Background

  • Released by Sun in 1995

  • Object-oriented

  • Rich libraries – pre-written software

  • Active programmer community

  • API Specification

    • Application Programming Interface

  • Extremely platform-independent

cosc236/intro


Java advantages

Java Advantages

  • Platform independence

  • Reuse of code

  • Security

  • Automatic garbage collection

  • Stronger typing of objects and variables

Columbia University JETT


Java programming environment

Java Programming Environment

  • Type program as Java class =>.java

  • Compile => .class (bytecode)

  • Loader – connects bytecode from various classes and loads bytecode into main memory

  • Interpreter – translate and run

cosc236/intro


Sample program

Sample program

public class Hello

{

public static void main(String[] args)

{

System.out.println("Hello World!“);

}

}

cosc236/intro


Java programs

Java programs

  • class Hello

  • Class names begin with capital letter

  • file Hello.java

  • Class name and file name must match

cosc236/intro


Class

class

  • Unit of code that is the basic building block of java programs

    public class <name> //class header

    {

    <method>

    <method>

    <method>

    }

    main method is required

    public static void main(String[] args)

cosc236/intro


Methods

methods

  • particular action or calculation

  • main method is required

  • Method header

    public static void main(String[] args)

    {

    statements

    }

cosc236/intro


Statements

statements

  • Command

  • Statements end with ;

cosc236/intro


System out println

System.out.println

  • Line of output sent to console window

  • System.out.println("Hello World!“);

  • System.out.println();

  • System.out.print(“Hello”);

  • //does not move to next line of output

cosc236/intro


Literal string

Literal string

  • Surrounded by quotes

  • One line

  • Escape sequences

    \ttab

    \n new line

    \”quotation

    \\backslash

  • System.out.println(" \"Slick\" Willy");

  • "Slick" Willy

cosc236/intro


Example

Example

System.out.println("This\nyields three lines\nof output\n");

This

yields three lines

of output

cosc236/intro


Identifiers

Identifiers

  • used to name variables, constants, methods, classes, and data types

  • Rules:

    • must start with letter or underscore or $

    • Composed of letters, digits, $, or underscore (better to start with a letter)

  • Using Meaningful, Readable Identifiers!

  • Java is case sensitive

  • Don't use reserved words

cosc236/intro


Identifiers1

Legal:

firstName

conversion

lengthOfRoom

payRate

counter1

x

Illegal

first name

Hello!

5th

one+two

Identifiers

cosc236/intro


Identifiers style

Identifiers - Style

  • Class name

    • Begin with capital letter

  • Method

    • Begin with lowercase

    • Exa: calcPay,getInfo, sum

  • Constants: all caps

    • PI, MAX_HOURS, UNIV_NAME

cosc236/intro


Comments

Comments

  • Compiler ignores comments

  • /* */ everything between pair is ignored

  • // - everything after the two slashes to the end of line is ignored

  • header comment:

    • //Project number

    • //Student's nameDate project is due

    • //Course number

    • //Purpose of the program

cosc236/intro


When to use comments

When to use comments

  • Comment variable and constant declarations.

  • Precede blocks of code with an explanatory comment.

  • Explain statements that are not obvious.

  • Precede each class with a brief header comment

cosc236/intro


Readability

Readability

  • Class and method headers on lines by themselves

  • One statement per line

  • Indent

  • Use whitespace liberally in the form of blank lines and spaces.

  • Include at least one blank line between methods

cosc236/intro


Syntax

Syntax

  • Syntax - formal set of rules governing how valid instructions are written in a programming language

cosc236/intro


Program errors

Program Errors

  • Syntax error – error in using Java, indicated by compiler

    • Cannot execute

    • Exa: File name does not match class name

  • Logic error (bug) – code doesn't perform the intended task

    • debugging

cosc236/intro


Structured programming

Structured Programming

  • Control structures

    • sequence

    • selection

    • Loop

  • Modularity/Top-Down Design

    • Decomposition – separation into parts

    • Functions, procedures => methods

cosc236/intro


Static method

Static method

  • A block of statements that is given a name

  • Static

    • allows non object-oriented invocation

    • Use no instance variable of any object they are declared in

  • Method call

    • Transfers control

  • Methods can call other methods

cosc236/intro


Overview of the computer

public class Memo

{

public static void main(String[] args)

{

printLogo(); //method call

System.out.println("Reminder:" );

System.out.println("Company Meeting");

System.out.println("Thursday at 9:00!!!!");

printLogo();

} /* end main */

public static void printLogo() // method header

{

System.out.println("*************************************");

System.out.println("**********YOUR COMPANY********");

System.out.println("*************************************");

}

}

cosc236/intro


Design plan the solution

Design/Plan the solution

  • Algorithm – a step by step procedure for solving a problem, ordered set of instructions such that:

  • programs are implementations of algorithms, emphasis on writing algorithms.

  • the computer is a fast and flexible tool for implementing algorithms.

  • tools

    • flowcharts

    • Pseudocode

    • subtasks - hierarchy chart

  • test solution for correctness - trace

cosc236/intro


  • Login