0% found this document useful (0 votes)
66 views

Computing 1 Unit 1 Overview of Computer

This document provides an overview of computers and programming languages. It discusses the hardware and software components of computers, including the central processing unit, memory, input/output devices, operating systems, and application programs. It also covers the evolution of programming languages from machine language to high-level languages like Java. Key topics include the history of computers, language translation via compilers, and how Java code is processed.

Uploaded by

api-26781128
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Computing 1 Unit 1 Overview of Computer

This document provides an overview of computers and programming languages. It discusses the hardware and software components of computers, including the central processing unit, memory, input/output devices, operating systems, and application programs. It also covers the evolution of programming languages from machine language to high-level languages like Java. Key topics include the history of computers, language translation via compilers, and how Java code is processed.

Uploaded by

api-26781128
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 40

Chapte r 1 : An O ve rv iew of

Com put er s a nd P rogra mmi ng


La nguage s

Java Programming:
From Problem Analysis to Program Design,
Second Edition

TCC 101 Computing 1 School of Science and Technology


Chapter Objectives
• Learn about different types of computers.
• Explore the hardware and software
components of a computer system.
• Learn about the language of a computer.
• Learn about the evolution of
programming languages.
• Examine high-level programming
languages.
• Discover what a compiler is and what it
does.
Java Programming: From Problem Analysis to Program Design, Second
2 Ed
TCC 101 Computing 1 School of Science and Technology
Chapter Objectives
• Examine a Java program.
• Examine how a Java program is processed.
• Become aware of the Internet and World Wide
Web.
• Learn what an algorithm is and explore
problem-solving techniques.
• Become aware of structured and object-
oriented programming design methodologies.

Java Programming: From Problem Analysis to Program Design, Second


3 Ed
TCC 101 Computing 1 School of Science and Technology
Introduction
• Computers have greatly affected our daily lives
— helping us complete many tasks.

• Computer programs (software) are designed


specifically for each task.

• Software is created with programming


languages.

• Java is an example of a programming language.

Java Programming: From Problem Analysis to Program Design, Second


4 Ed
TCC 101 Computing 1 School of Science and Technology
An Overview of the
History of Computers
• 1950s: Very large devices available to a select
few.

• 1960s: Large corporations owned computers.

• 1970s: Computers got smaller and cheaper.

• 1990s: Computers got cheaper and faster and


were found in most homes.

Java Programming: From Problem Analysis to Program Design, Second


5 Ed
TCC 101 Computing 1 School of Science and Technology
Elements of a Computer System
A computer has two components:

– Hardware

– Software

Java Programming: From Problem Analysis to Program Design, Second


6 Ed
TCC 101 Computing 1 School of Science and Technology
Hardware Components
of a Computer
• Central processing unit (CPU)

• Main memory

Java Programming: From Problem Analysis to Program Design, Second


7 Ed
TCC 101 Computing 1 School of Science and Technology
Central Processing Unit
• Control unit (CU)

• Arithmetic logic unit (ALU)

• Program counter (PC)

• Instruction register (IR)

Java Programming: From Problem Analysis to Program Design, Second


8 Ed
TCC 101 Computing 1 School of Science and Technology
Hardware Components of a Computer

Java Programming: From Problem Analysis to Program Design, Second


9 Ed
TCC 101 Computing 1 School of Science and Technology
Main Memory
• Ordered sequence of cells (memory cells).

• Directly connected to CPU.

• All programs must be brought into main


memory before execution.

• When power is turned off, everything in


main memory is lost.

Java Programming: From Problem Analysis to Program Design, Second


10 Ed
TCC 101 Computing 1 School of Science and Technology
Main Memory with
100 Storage Cells

Java Programming: From Problem Analysis to Program Design, Second


11 Ed
TCC 101 Computing 1 School of Science and Technology
Secondary Storage
• Provides permanent storage for
information.
• Examples of secondary storage:
– Hard disks
– Floppy disks
– Zip disks
– CD-ROMs
– Tapes
Java Programming: From Problem Analysis to Program Design, Second
12 Ed
TCC 101 Computing 1 School of Science and Technology
Input Devices
• Devices that feed data and computer
programs into computers.

• Examples:

– Keyboard

– Mouse

– Secondary storage

Java Programming: From Problem Analysis to Program Design, Second


13 Ed
TCC 101 Computing 1 School of Science and Technology
Output Devices
• Devices that the computer uses to display
results.

• Examples:
– Printer

– Monitor

– Secondary storage

Java Programming: From Problem Analysis to Program Design, Second


14 Ed
TCC 101 Computing 1 School of Science and Technology
Software
• Software consists of programs written to
perform specific tasks.

• Two types of programs:

– System programs

– Application programs

Java Programming: From Problem Analysis to Program Design, Second


15 Ed
TCC 101 Computing 1 School of Science and Technology
System Programs
• System programs control the computer.

• The operating system is first to load when


you turn on a computer.

Java Programming: From Problem Analysis to Program Design, Second


16 Ed
TCC 101 Computing 1 School of Science and Technology
Operating System (OS)
• The OS monitors the overall activity of the
computer and provides services.
• Example services:
– Memory management
– Input/output
– Activities
– Storage management

Java Programming: From Problem Analysis to Program Design, Second


17 Ed
TCC 101 Computing 1 School of Science and Technology
Application Programs
• Written using programming languages.
• Perform a specific task.
• Run by the OS.
• Example programs:
– Word processors
– Spreadsheets
– Games

Java Programming: From Problem Analysis to Program Design, Second


18 Ed
TCC 101 Computing 1 School of Science and Technology
Language of a Computer
• Machine language is the most basic
language of a computer.
• A sequence of 0s and 1s.
• Every computer directly understands its
own machine language.
• A bit is a binary digit, 0 or 1.
• A byte is a sequence of eight bits.

Java Programming: From Problem Analysis to Program Design, Second


19 Ed
TCC 101 Computing 1 School of Science and Technology
Language of a Computer

Java Programming: From Problem Analysis to Program Design, Second


20 Ed
TCC 101 Computing 1 School of Science and Technology
Evolution of
Programming Languages
• Early computers programmed in machine
language.
• Assembly languages were developed to make
programmer’s job easier.
• In assembly language, an instruction is an easy-
to-remember form called a mnemonic.
• Assembler: Translates assembly language
instructions into machine language.

Java Programming: From Problem Analysis to Program Design, Second


21 Ed
TCC 101 Computing 1 School of Science and Technology
Instructions in Assembly and
Machine Languages

Java Programming: From Problem Analysis to Program Design, Second


22 Ed
TCC 101 Computing 1 School of Science and Technology
Evolution of
Programming Languages
• High-level languages make programming
easier.
• Closer to spoken languages.
• Examples:
– Basic
– FORTRAN
– COBOL
– C/C++
– Java
Java Programming: From Problem Analysis to Program Design, Second
23 Ed
TCC 101 Computing 1 School of Science and Technology
Evolution of
Programming Languages
To run a Java program:

2. Java instructions need to be translated into


an intermediate language called bytecode.

3. The bytecode is interpreted into a particular


machine language.

Java Programming: From Problem Analysis to Program Design, Second


24 Ed
TCC 101 Computing 1 School of Science and Technology
Evolution of
Programming Languages
• Compiler: A program that translates a
program written in a high-level language into
the equivalent machine language.
– (In the case of Java, this machine language is
the bytecode.)

• Java Virtual Machine (JVM): A hypothetical


computer developed to make Java programs
machine independent.

Java Programming: From Problem Analysis to Program Design, Second


25 Ed
TCC 101 Computing 1 School of Science and Technology
Compilers and
Inter preter s
class HelloWorld {
public static void main (String [ ] args) {
System.out.println(“Hello World”);
} // end main method
} // end HelloWorld class

001001110111101
111010001111010
001011101010111
001110101001110
Compilers translate source code into machine
readable/executable files all at once.

Interpreters translate source code into machine


readable/executable files one line at a time (piecemeal).
TCC 101 Computing 1 School of Science and Technology
Why Java ?
Write Once, Run Anywhere
(Platform Independence)

Platform Dependence:
Each application has to be written once for
Windows, once for Macs, once for UNIX, etc.

Platform Independence :
Each application is written just once in order to run
on all of Windows, Macs, UNIX, etc.
TCC 101 Computing 1 School of Science and Technology
Why Java ?

A powerful library of portable code

Java’s Standard API

(Applications Programming Interface)

With additional libraries


available for specific
development efforts

TCC 101 Computing 1 School of Science and Technology


What’ s in Java ’s
API?
Easy-to-use components for:

GUIs
Graphical User Interfaces

Applets
Safe executables for the Web

Applications
General all-purpose programming

TCC 101 Computing 1 School of Science and Technology


A Java Program
public class ASimpleJavaProgram {
public static void main(String[] args) {
System.out.println("My first Java program.");
System.out.println("The sum of 2 and 3 = " + 5);
System.out.println("7 + 8 = " + (7 + 8));
}
}

Sample Run:
My first Java program.
The sum of 2 and 3 = 5
7 + 8 = 15

Java Programming: From Problem Analysis to Program Design, Second


30 Ed
TCC 101 Computing 1 School of Science and Technology
Processing a Java Program
• Two types of Java programs are applications
and applets.
• Source program: Written in a high-level
language.
• Loader: Transfers the compiled code
(bytecode) into main memory.
• Interpreter: Reads and translates each
bytecode instruction into machine language
and then executes it.
Java Programming: From Problem Analysis to Program Design, Second
31 Ed
TCC 101 Computing 1 School of Science and Technology
Processing a Java Program

Java Programming: From Problem Analysis to Program Design, Second


32 Ed
TCC 101 Computing 1 School of Science and Technology
Problem-Analysis-Coding-
Execution Cycle
• Algorithm: A step-by-step, problem-solving
process in which a solution is arrived at in
a finite amount of time.

Java Programming: From Problem Analysis to Program Design, Second


33 Ed
TCC 101 Computing 1 School of Science and Technology
Problem-Solving Process
• Analyze the problem: Outline solution
requirements and design an algorithm.

• Implement the algorithm in a


programming language (Java) and verify
that the algorithm works.

• Maintain the program: Use and modify if


the problem domain changes.

Java Programming: From Problem Analysis to Program Design, Second


34 Ed
TCC 101 Computing 1 School of Science and Technology
Problem-Analysis-Coding-Execution
Cycle

Java Programming: From Problem Analysis to Program Design, Second


35 Ed
TCC 101 Computing 1 School of Science and Technology
Programming Methodologies
Two basic approaches to programming
design:

– Structured design

– Object-oriented design

Java Programming: From Problem Analysis to Program Design, Second


36 Ed
TCC 101 Computing 1 School of Science and Technology
Structured Design
1. A problem is divided into smaller sub-
problems.

2. Each sub-problem is solved.

3. The solutions of all sub-problems are


combined to solve the problem.

Java Programming: From Problem Analysis to Program Design, Second


37 Ed
TCC 101 Computing 1 School of Science and Technology
Object-Oriented Design (OOD)
• In OOD, a program is a collection of
interacting objects.
• An object consists of data and
operations.
• Steps in OOD:
1. Identify objects.
2. Form the basis of the solution.
3. Determine how these objects interact.
Java Programming: From Problem Analysis to Program Design, Second
38 Ed
TCC 101 Computing 1 School of Science and Technology
Chapter Summary
• A computer system is made up of hardware and
software components.
• Computers understand machine language; it is
easiest for programmers to write in high-level
languages.
• A compiler translates high-level language into
machine language.
• The Java steps required to execute a program
are edit, compile, load, and execute.

Java Programming: From Problem Analysis to Program Design, Second


39 Ed
TCC 101 Computing 1 School of Science and Technology
Chapter Summary
• An algorithm is a step-by-step, problem-solving
process in which a solution is arrived at in a
finite amount of time.
• The three steps of the problem-solving process
are analyze the problem and design an
algorithm, implement the algorithm in a
programming language, and maintain the
program.
• The two basic approaches to programming
design are structured design and object-oriented
design.
Java Programming: From Problem Analysis to Program Design, Second
40 Ed
TCC 101 Computing 1 School of Science and Technology

You might also like