0% found this document useful (0 votes)
109 views41 pages

Java Programming: From Problem Analysis To Program Design, 3e

The chapter introduces key concepts about computers and programming languages. It discusses the evolution of computers from early mechanical devices to modern electronic computers. It also covers the hardware components of a computer system and software components. The chapter then explains the evolution of programming languages from low-level machine language to high-level languages like Java. It discusses how a Java program is processed through compilation and interpretation. Finally, it introduces algorithms and problem-solving techniques for programming.

Uploaded by

Tsuna Rinku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views41 pages

Java Programming: From Problem Analysis To Program Design, 3e

The chapter introduces key concepts about computers and programming languages. It discusses the evolution of computers from early mechanical devices to modern electronic computers. It also covers the hardware components of a computer system and software components. The chapter then explains the evolution of programming languages from low-level machine language to high-level languages like Java. It discusses how a Java program is processed through compilation and interpretation. Finally, it introduces algorithms and problem-solving techniques for programming.

Uploaded by

Tsuna Rinku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Java Programming: From Problem

Analysis to Program Design, 3e

Chapter 1
An Overview of Computers and
Programming Languages
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
Java Programming: From Problem Analysis to Program Design, 3e 2
Chapter Objectives (continued)
• Discover what a compiler is and what it
does
• Examine how a Java program is processed
• 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, 3e 3
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, 3e 4
An Overview of the History of
Computers
• The first device known to carry out
calculations was the abacus
• The abacus uses a system of sliding beads
on a rack for addition and subtraction
• Blaise Pascal invented the calculating
device called the Pascaline

Java Programming: From Problem Analysis to Program Design, 3e 5


An Overview of the History of
Computers (continued)
• In 1819, Joseph Jacquard, a French weaver,
discovered that the weaving instructions for
his looms could be stored on cards with
holes punched in them
• In the early and mid-1800s, Charles
Babbage, an English mathematician and
physical scientist, designed two calculating
machines—the difference engine and the
analytical engine
Java Programming: From Problem Analysis to Program Design, 3e 6
An Overview of the History of
Computers (continued)
• The first computer-like machine was the
Mark I
– Built in 1944
– Used punched cards to feed data into the
machine
– 52 feet long, weighed 50 tons, and had 750,000
parts
• In 1946, ENIAC (Electronic Numerical
Integrator and Calculator) was built at the
University of Pennsylvania.
– Contained 18,000 vacuum tubes and weighed
some 30 tons
Java Programming: From Problem Analysis to Program Design, 3e 7
An Overview of the History of
Computers (continued)
• In 1956, the invention of the transistors
resulted in smaller, faster, more reliable,
and more energy-efficient computers
• This era also saw the emergence of the
software development industry with the
introduction of FORTRAN and COBOL,
two early programming languages
• In 1970, the microprocessor, an entire CPU
on a single chip, was invented

Java Programming: From Problem Analysis to Program Design, 3e 8


An Overview of the History of
Computers (continued)
• In 1977, Stephen Wozniak and Steven Jobs
designed and built the first Apple computer
in their garage
• In 1981, IBM introduced its personal
computer (PC)
• Modern-day computers are very powerful,
reliable, and easy to use
– Can accept spoken-word instructions and
imitate human reasoning through artificial
intelligence
Java Programming: From Problem Analysis to Program Design, 3e 9
An Overview of the History of
Computers (continued)
• Although there are several categories of
computers, such as mainframe, midsize, and
micro, all computers share some basic
elements

Java Programming: From Problem Analysis to Program Design, 3e 10


Elements of a Computer System
• A computer has 2 components
– Hardware
– Software

Java Programming: From Problem Analysis to Program Design, 3e 11


Hardware Components of a
Computer
• Central Processing Unit (CPU)
• Main Memory

Java Programming: From Problem Analysis to Program Design, 3e 12


Central Processing Unit

• Control Unit (CU)


• Arithmetic Logic Unit (ALU)
• Program Counter (PC)
• Instruction Register (IR)

Java Programming: From Problem Analysis to Program Design, 3e 13


Central Processing Unit (continued)

Java Programming: From Problem Analysis to Program Design, 3e 14


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, 3e 15


Main Memory with 100 Storage
Cells

Java Programming: From Problem Analysis to Program Design, 3e 16


Secondary Storage
• Provides permanent storage for information
• Examples of secondary storage:
– Hard Disks
– Floppy Disks
– Flash memory
– ZIP Disks
– CD-ROMs
– Tapes

Java Programming: From Problem Analysis to Program Design, 3e 17


Input Devices
• Definition: devices that feed data and
computer programs into computers
• Examples
– Keyboard
– Mouse
– Secondary Storage

Java Programming: From Problem Analysis to Program Design, 3e 18


Output Devices
• Definition: devices that the computer uses
to display results
• Examples
– Printer
– Monitor
– Secondary Storage

Java Programming: From Problem Analysis to Program Design, 3e 19


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, 3e 20


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, 3e 21


Operating System (OS)
• OS monitors 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, 3e 22


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, 3e 23


Language of a Computer

• Machine language: 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, 3e 24
Language of a Computer (continued)

Java Programming: From Problem Analysis to Program Design, 3e 25


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, 3e 26
Instructions in Assembly and
Machine Language

Java Programming: From Problem Analysis to Program Design, 3e 27


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, 3e 28
Evolution of Programming
Languages (continued)
• To run a Java program
1. Java instructions need to be translated into an
intermediate language called bytecode
2. Then the bytecode is interpreted into a
particular machine language

Java Programming: From Problem Analysis to Program Design, 3e 29


Evolution of Programming
Languages (continued)
• 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): hypothetical
computer developed to make Java programs
machine independent

Java Programming: From Problem Analysis to Program Design, 3e 30


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, 3e 31


Processing a Java Program
• Two types of Java programs: 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, 3e 32


Processing a Java Program
(continued)

Java Programming: From Problem Analysis to Program Design, 3e 33


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, 3e 34


Problem-Solving Process

1. Analyze the problem: outline solution


requirements and design an algorithm
2. Implement the algorithm in a
programming language (Java) and verify
that the algorithm works
3. Maintain the program: use and modify if
the problem domain changes

Java Programming: From Problem Analysis to Program Design, 3e 35


Problem-Analysis-Coding-
Execution Cycle

Java Programming: From Problem Analysis to Program Design, 3e 36


Programming Methodologies
• Two basic approaches to programming
design
– Structured design
– Object-oriented design

Java Programming: From Problem Analysis to Program Design, 3e 37


Structured Design
1. A problem is divided into smaller
subproblems
2. Each subproblem is solved
3. The solutions of all subproblems are then
combined to solve the problem

Java Programming: From Problem Analysis to Program Design, 3e 38


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, 3e 39


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
• Java steps to execute a program: edit, compile,
load, and execute

Java Programming: From Problem Analysis to Program Design, 3e 40


Chapter Summary (continued)
• Algorithm: step-by-step problem-solving process
in which a solution is arrived at in a finite amount
of time
• Three steps to problem solving: analyze the
problem and design an algorithm, implement the
algorithm in a programming language, and
maintain the program
• Two basic approaches to programming design:
structured and object-oriented

Java Programming: From Problem Analysis to Program Design, 3e 41

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy