Download presentation
Presentation is loading. Please wait.
1
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition
2
Java Programming: From Problem Analysis to Program Design, Second Edition2 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.
3
Java Programming: From Problem Analysis to Program Design, Second Edition3 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.
4
Java Programming: From Problem Analysis to Program Design, Second Edition4 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.
5
Java Programming: From Problem Analysis to Program Design, Second Edition5 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.
6
Java Programming: From Problem Analysis to Program Design, Second Edition6 Elements of a Computer System A computer has two components: Hardware Software
7
Java Programming: From Problem Analysis to Program Design, Second Edition7 Hardware Components of a Computer Central processing unit (CPU) Main memory
8
Java Programming: From Problem Analysis to Program Design, Second Edition8 Central Processing Unit Control unit (CU) Arithmetic logic unit (ALU) Program counter (PC) Instruction register (IR)
9
Java Programming: From Problem Analysis to Program Design, Second Edition9 Hardware Components of a Computer
10
Java Programming: From Problem Analysis to Program Design, Second Edition10 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.
11
Java Programming: From Problem Analysis to Program Design, Second Edition11 Main Memory with 100 Storage Cells
12
Java Programming: From Problem Analysis to Program Design, Second Edition12 Secondary Storage Provides permanent storage for information. Examples of secondary storage: Hard disks Floppy disks Zip disks CD-ROMs Tapes
13
Java Programming: From Problem Analysis to Program Design, Second Edition13 Input Devices Devices that feed data and computer programs into computers. Examples: Keyboard Mouse Secondary storage
14
Java Programming: From Problem Analysis to Program Design, Second Edition14 Output Devices Devices that the computer uses to display results. Examples: Printer Monitor Secondary storage
15
Java Programming: From Problem Analysis to Program Design, Second Edition15 Software Software consists of programs written to perform specific tasks. Two types of programs: System programs Application programs
16
Java Programming: From Problem Analysis to Program Design, Second Edition16 System Programs System programs control the computer. The operating system is first to load when you turn on a computer.
17
Java Programming: From Problem Analysis to Program Design, Second Edition17 Operating System (OS) The OS monitors the overall activity of the computer and provides services. Example services: Memory management Input/output Activities Storage management
18
Java Programming: From Problem Analysis to Program Design, Second Edition18 Application Programs Written using programming languages. Perform a specific task. Run by the OS. Example programs: Word processors Spreadsheets Games
19
Java Programming: From Problem Analysis to Program Design, Second Edition19 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.
20
Java Programming: From Problem Analysis to Program Design, Second Edition20 Language of a Computer
21
Java Programming: From Problem Analysis to Program Design, Second Edition21 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.
22
Java Programming: From Problem Analysis to Program Design, Second Edition22 Instructions in Assembly and Machine Languages
23
Java Programming: From Problem Analysis to Program Design, Second Edition23 Evolution of Programming Languages High-level languages make programming easier. Closer to spoken languages. Examples: Basic FORTRAN COBOL C/C++ Java
24
Java Programming: From Problem Analysis to Program Design, Second Edition24 Evolution of Programming Languages To run a Java program: 1.Java instructions need to be translated into an intermediate language called bytecode. 2.The bytecode is interpreted into a particular machine language.
25
Java Programming: From Problem Analysis to Program Design, Second Edition25 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.
26
Java Programming: From Problem Analysis to Program Design, Second Edition26 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
27
Java Programming: From Problem Analysis to Program Design, Second Edition27 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.
28
Java Programming: From Problem Analysis to Program Design, Second Edition28 Processing a Java Program
29
Java Programming: From Problem Analysis to Program Design, Second Edition29 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.
30
Java Programming: From Problem Analysis to Program Design, Second Edition30 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.
31
Java Programming: From Problem Analysis to Program Design, Second Edition31 Problem-Solving Process Example: Find the perimeter and area of a rectangle. 1.Get the length of the rectangle. 2. Get the width of the rectangle. 3.Find the perimeter using the equation: Perimeter = 2 * (length + width) 4.Find the area using the equation: Area = length * width
32
Java Programming: From Problem Analysis to Program Design, Second Edition32 Problem-Analysis-Coding-Execution Cycle
33
Java Programming: From Problem Analysis to Program Design, Second Edition33 Programming Methodologies Two basic approaches to programming design: Structured design Object-oriented design
34
Java Programming: From Problem Analysis to Program Design, Second Edition34 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.
35
Java Programming: From Problem Analysis to Program Design, Second Edition35 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.
36
Java Programming: From Problem Analysis to Program Design, Second Edition36 Object-Oriented Design (OOD) Write a program to automate the video rental process for a local video store. Two objects : the video and the customer. Data with video object: movie name,starring actors,# of copies in stock. Operations on the video object: reducing the number of copies in stock. So each object consist of data and operations on those data
37
Java Programming: From Problem Analysis to Program Design, Second Edition37 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.
38
Java Programming: From Problem Analysis to Program Design, Second Edition38 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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.