1 / 39

Overview of Computers and Programming Languages

Explore the types of computers, hardware and software components, language of computers, and evolution of programming languages. Learn about compilers, algorithms, and programming design methodologies.

corineg
Download Presentation

Overview of Computers and Programming Languages

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 1 An Overview of Computers and Programming Languages

  2. 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

  3. Chapter Objectives • 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

  4. Introduction • Computers have greatly effected 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. An Overview of the History of Computers • 1950s: Very large devices available to a select few • 1960s: Large corporations owned computers • 1970s: Computers get smaller and cheaper • 1990s: Computers get cheaper and faster and are found in most homes

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

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

  8. Central Processing Unit • Control Unit (CU) • Arithmetic Logic Unit (ALU) • Program Counter (PC) • Instruction Register (IR) • Accumulator (ACC)

  9. 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

  10. Main Memory with 100 Storage Cells

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

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

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

  14. Hardware Components of a Computer

  15. Software • Software consists of programs written to perform specific tasks • Two types of programs • System Programs • Application Programs

  16. System Programs • System programscontrol the computer • The operating system is first to load when you turn on a computer

  17. Operating System (OS) • OS monitors overall activity of the computer and provides services • Example services: • memory management • input/output • activities • storage management

  18. Application Programs • Written using programming languages • Perform a specific task • Run by the OS • Example programs: • Word Processors • Spreadsheets • Games

  19. 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

  20. 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

  21. Instructions in Assembly and Machine Language

  22. Evolution of Programming Languages • High-level languagesmake programming easier • Closer to spoken languages • Examples: • Basic • FORTRAN • COBOL • C/C++ • Java

  23. Evolution of Programming Languages • To run a Java program: • Java instructions need to be translated into an intermediate language called bytecode • Then the bytecode is interpreted into a particular machine language

  24. 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) - hypothetical computer developed to make Java programs machine independent

  25. Processing a Java Program • Two types of Java programs: applications and applets • Source program: Written in a high-level language • Linker: Combines bytecode with other programs provided by the SDK and creates executable code • Loader: transfers executable code into main memory • Interpreter: reads and translates each bytecode instruction into machine language and then executes it

  26. Processing a Java Program

  27. 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

  28. 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

  29. Problem-Analysis-Coding-Execution Cycle

  30. Programming Methodologies • Two basic approaches to programming design: • Structured design • Object-oriented design

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

  32. Object-Oriented Design (OOD) • In OOD, a program is a collection of interacting objects • An object consists of data and operations • Steps in OOD: • Identify objects • Form the basis of the solution • Determine how these objects interact

  33. Example 1-1 Design an algorithm to find the perimeter and area of a rectangle. The perimeter and area of the rectangle are given by the following formulas: perimeter = 2 · (length + width) area = length · width

  34. The algorithm to find the perimeter and area of the rectangle is, therefore: 1. Get the length of the rectangle. 2. Get the width of the rectangle. 3. Find the perimeter using the following equation: perimeter = 2 · (length + width) 4. Find the area using the following equation: area = length · width

  35. Example 1-2 Design an algorithm that calculates the monthly paycheck of a sales-person at a local department store. Every salesperson has a base salary. The salesperson also receives a bonus at the end of each month based on the following criteria: If the salesperson has been with the store for five or less years, the bonus is $10 for each year that he or she has worked there. If the salesperson has been with the store for more than five years, the bonus is $20 for each year that he or she has worked there. The salesperson can earn an additional bonus as follows: If the total sale made by the salesperson for the month is more than $5000 but less than $10000, he or she receives a 3% commission on the sale. If the total sale made by the salesperson for the month is at least $10000, he or she receives a 6% commission on the sale.

  36. The algorithm to calculate a salesperson’s monthly paycheck. 1. Get baseSalary. 2. Get noOfServiceYears. 3. Compute the bonus by the following: if(noOfServiceYears is less than or equal to five) bonus = 10 · noOfServiceYears otherwise bonus = 20 · noOfServiceYears 4. Get totalSale.

  37. 5. Calculate additionalBonus using the following formula. if (totalSale is less than 5000) additionalBonus = 0 otherwise if(totalSale is greater than or equal to 5000 and totalSale is less than 10000) additionalBonus = totalSale · (0.03) otherwise additionalBonus = totalSale · (0.06) 6. Calculate payCheck using the equation payCheck = baseSalary + bonus + additionalBonus

  38. 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 • High-level language steps to execute a program: edit, compile, link, load, and execute

  39. Chapter Summary • 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

More Related