structured problem solving using the computer it 168 aug
play

Structured Problem-Solving Using the Computer IT 168 Aug 23, 2012 - PowerPoint PPT Presentation

Structured Problem-Solving Using the Computer IT 168 Aug 23, 2012 (Thursday) Interesting story about Light, electrons, mechanical components Hex edit For Tuesday(Aug 28) Read Gaddis, chapter 2, sections 1-6


  1. Structured Problem-Solving Using the Computer IT 168 Aug 23, 2012 (Thursday)

  2. Interesting story about … • Light, electrons, mechanical components • Hex edit • …

  3. For Tuesday(Aug 28) • Read Gaddis, chapter 2, sections 1-6 • Download and complete the student questionnaire • Send the completed questionnaire to kwsuh@ilstu.edu from your ISU email address. Include your name, IT 168, and your lecture section by Tuesday • Any concerns/comments about the first lab?

  4. Quiz • Next week • Ch1, Ch2.1-2.6, syllabus

  5. Computer Systems: Hardware • Computer hardware components are the physical pieces of the computer. • The major hardware components of a computer are: – The central processing unit (CPU) – Main memory – Secondary storage devices – Input and Output devices 1-5

  6. Computer Systems: Hardware 1-6

  7. Computer Systems: Hardware Central Processing Unit CPU Arithmetic Logic Unit Instruction (input) Result (output) Control Unit 1-7

  8. Computer Systems: Hardware Central Processing Unit – The CPU performs the fetch, decode, execute cycle in order to process program information. The CPU’s control unit fetches, from main memory, the next instruction in the sequence of program instructions. Fetch The instruction is encoded in the form of a number. The control unit decodes the instruction and generates an electronic signal. The signal is routed to the appropriate component Execute Decode of the computer (such as the ALU, a disk drive, or some other device). The signal causes the component to perform an operation. 1-8

  9. Computer Systems: Hardware Main Memory • Commonly known as random-access memory (RAM) • RAM contains: – currently running programs – data used by those programs. • RAM is divided into units called bytes . • A byte consists of eight bits that may be either on or off. 1-9

  10. Computer Systems: Hardware Main Memory • A bit is either on or off: – 1 = on – 0 = off • The bits form a pattern that represents a character or a number. • Each byte in memory is assigned a unique number known as an address . • RAM is volatile , which means that when the computer is turned off, the contents of RAM are erased. 1-10

  11. Computer Systems: Hardware Main Memory Main memory can be visualized as a column or row of cells. 0x000 A section of memory is called a byte . 0x001 A byte is made up of 8 bits . 1 0 1 0 1 0 1 0 0x002 0x003 0x004 0x005 A section of two or four bytes is 0x006 often called a word . 0x007 [Q] 32-bit computer vs. 64-bit computer? 1-11

  12. Computer Systems: Hardware Secondary Storage Devices • Secondary storage devices are capable of storing information for longer periods of time ( non-volatile ). • Common Secondary Storage devices: • Hard drive • CD ROM • Floppy drive • DVD RAM drive • CD RW drive • Compact Flash card 1-12

  13. Computer Systems: Hardware Input Devices • Input is any data the computer collects from the outside world. • That data comes from devices known as input devices . • Common input devices: – Keyboard – Mouse – Scanner – Digital camera 1-13

  14. Computer Systems: Hardware Output Devices • Output is any data the computer sends to the outside world. • That data is displayed on devices known as output devices . • Common output devices: – Monitors – Printers • Some devices such as disk drives perform input and output and are called I/O devices (input/output). 1-14

  15. What can a computer do? • Simple arithmetic – Add, subtract, (multiply, divide) • Move data – From CPU to memory and vice-versa – From CPU to I/O device and vice-versa – Between registers inside CPU • Compare two numbers (and move data based on the result of the comparison) • ….

  16. How do we do cool stuff?

  17. Computer Systems: Software • Software refers to the programs that run on a computer. • There are two classifications of software: – Operating Systems and system software – Application Software 1-17

  18. Programming Languages • A program is a set of instructions a computer follows in order to perform a task. • A programming language is a special language used to write computer programs. • A computer program is a set of instructions that enable the computer to solve a problem or perform a task. • Collectively, these instructions form an algorithm 1-18

  19. Programming Languages • An algorithm is a set of well defined steps to completing a task. • The steps in an algorithm are performed sequentially. • A computer needs the algorithm to be written in machine language . • Machine language is written using binary numbers . • The binary numbering system (base 2) only has two digits (0 and 1). 1-19

  20. Programming Languages • The binary numbers are encoded as a machine language . • Each CPU has its own machine language. – Motorola 68000 series processors – Intel x86 series processors – DEC Alpha processors, etc. • Example of a machine language instruction: 1011010000000101 1-20

  21. Programming Languages • In the distant past, programmers wrote programs in machine language. • Programmers developed higher level programming languages to make things easier. • The first of these was assembler . • Assembler made things easier but was also processor dependent. 1-21

  22. Programming Languages • High level programming languages followed that were not processor dependent. • Some common programming languages: – BASIC – COBOL – Pascal – C – C++ – Java 1-22

  23. The Process 1. Understand the problem 2. Figure out the interface (input and output) 3. Make a plan 4. Check the plan 5. Translate the plan into Java (or other) 6. Fix compile-time errors 7. Run the program 8. Fix run-time errors 9. Make sure it works correctly

  24. Errors • Syntax or compile-time • Run-time • Logic or intent

  25. Making the Plan • Algorithms • Pseudocode – English – Formatted like computer program code – http://www.unf.edu/~broggio/cop2221/2221pseu.ht m

  26. Terminology • Algorithm ≠ Pseudocode • Algorithms are often written in pseudocode, but your Java program is also a representation of an algorithm. • On the other hand, when I ask you to submit an algorithm, it MUST be written in pseudocode.

  27. Precision/Detail • How precise and detailed does an algorithm have to be? • Just exactly how dumb is a computer?

  28. Writing for an Audience • When you write a computer program, you have two audiences. • What are they?

  29. Demo • Let’s look at an actual computer program in Java.

  30. Structure of a Java Program

  31. Some Details • File name and class name • Case sensitivity • Comments • Curly braces • Semicolons • Quotation marks

  32. Output from Java

  33. Chapter 2: Java Fundamentals Starting Out with Java: Early Objects Fourth Edition by Tony Gaddis

  34. Chapter Topics Chapter 2 discusses the following main topics: – The Parts of a Java Program – The print and println Methods, and the Java API – Variables and Literals – Primitive Data Types – Arithmetic Operators – Combined Assignment Operators 2-34

  35. Chapter Topics (2) – Conversion between Primitive Data Types – Creating named constants with final – The String class – Scope – Comments – Programming style – Reading keyboard input – Dialog boxes – The printf method 2-35

  36. Parts of a Java Program • A Java source code file contains one or more Java classes. • If more than one class is in a source code file, only one of them may be public. • The public class and the filename of the source code file must match. ex: A class named Simple must be in a file named Simple.java • Each Java class can be separated into parts. 2-36

  37. Parts of a Java Program • See example: Simple.java • To compile the example: – javac Simple.java • Notice the .java file extension is needed. • This will result in a file named Simple.class being created. • To run the example: – java Simple • Notice there is no file extension here. • The java command assumes the extension is .class . 2-37

  38. Analyzing The Example This is a Java comment. // This is a simple Java program. It is ignored by the compiler. This is the class header public class Simple for the class Simple { This area is the body of the class Simple . All of the data and methods for this class will be between these curly braces. } 2-38

  39. Analyzing The Example This is the method header // This is a simple Java program. for the main method. The main method is where a Java application begins. public class Simple { public static void main(String[] args) { This area is the body of the main method. All of the actions to be completed during } the main method will be between these curly braces. } 2-39

  40. Analyzing The Example // This is a simple Java program. public class Simple { public static void main(String [] args) { System.out.println("Programming is great fun!"); } } This is the Java Statement that is executed when the program runs. 2-40

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend