Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.

Similar presentations


Presentation on theme: "CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture."— Presentation transcript:

1 CHAPTER 1 INTRODUCTION

2 CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture of computers To learn about the architecture of computers To learn about machine code and high level programming languages To learn about machine code and high level programming languages To become familiar with your computing environment and your compiler To become familiar with your computing environment and your compiler To compile and run your first Java program To compile and run your first Java program To recognize syntax and logic errors To recognize syntax and logic errors

3 PREREQUISITES Computer savvy (file management, text editing) Computer savvy (file management, text editing)  Problem solving skills  Time management  High school math (Geometry, Algebra II)  No prior programming background required

4 What do computers do? Help with organizing and writing term papers Help with organizing and writing term papers Help balance checkbooks Help balance checkbooks Keep track of students' grades Keep track of students' grades They are even good game machines They are even good game machines

5 How do computers do it? Computers must be programmed to perform tasks. Different tasks require different programs. Computers must be programmed to perform tasks. Different tasks require different programs. A computer program executes a sequence of very basic operations in rapid succession A computer program executes a sequence of very basic operations in rapid succession

6 What is a computer?  Central processing unit  Memory  Peripherals  Executes very simple instructions  Executes instructions very rapidly  General purpose device  Programs describe specific actions

7 Self Check 1. What is required to play a music CD on a computer? Ans: A program that reads the data on the CD and sends output to the speakers and the screen. 2. Why is a CD player less flexible than a computer? Ans: A CD player can do one thing–play music CDs. It cannot execute programs.

8 Self Check Cont… 3. Can a computer program develop the initiative to execute tasks in a better way than its programmers envisioned? Ans: No–the program simply executes the instruction sequences that the programmers have prepared in advance.

9 Central Processing Unit

10 CPU and what it does A single chip consisting of millions of transistors A single chip consisting of millions of transistors performs program control performs program control arithmetic operations arithmetic operations data movement data movement

11 A Memory Module with Memory Chips Figure 2: A Memory Module with Memory Chips

12 A Hard Disk Figure 3: A Hard Disk

13 A Motherboard Figure 4: A Motherboard

14 Schematic Diagram of a Computer Figure 5: Schematic Diagram of a Computer

15 The ENIAC Figure 6: The ENIAC

16 Self Check 4. Where is a program stored when it is not currently running? Ans: In secondary storage, typically a hard disk. 5. Which part of the computer carries out arithmetic operations, such as addition and multiplication? Ans: The central processing unit.

17 Programming Languages  Machine/Virtual Machine 21 40 16 100 163 240  Assembler iload intRate bipush 100 if_icmpgt intError  High-level language if (intRate > 100)...

18 Compilers Language specific Language specific Sophisticated programs that Sophisticated programs that translate logical statements such as ifs into sequences of computations, tests and jumps translate logical statements such as ifs into sequences of computations, tests and jumps find memory locations for variables find memory locations for variables and more... and more...

19 The Java Programming Language  Simple  Safe  Platform-independent ("write once, run anywhere")  Rich library  Designed for the internet

20 Applets on a Web Page Figure 7: Applets on a Web Page

21 VersionYearImportant New Features 1.01996 1.11997Inner classes 1.21998Swing, Collections 1.32000Performance enhancements 1.42002Assertions, XML 52004Generic classes, enhanced for loop, auto-boxing, enumerations 62006Library improvements Java Versions

22 Self Check 5. What are the two most important benefits of the Java language? Ans: Safety and portability. 6. How long does it take to learn the entire Java library? Ans: No one person can learn the entire library–it is too large.

23 HOMEWORK! Complete the computer room agreement form and have it signed by parent/guardian Complete the computer room agreement form and have it signed by parent/guardian Be sure you have a computer password Be sure you have a computer password Read and take notes section 1-1 through 1-6 and complete the self-check exercises. Read and take notes section 1-1 through 1-6 and complete the self-check exercises. italicized words -- vocabulary italicized words -- vocabulary boxes boxes points of interest (ENIAC) points of interest (ENIAC) p. 29 exercises R1.1 – R1.3 to be collected tomorrow with the self check exercises. p. 29 exercises R1.1 – R1.3 to be collected tomorrow with the self check exercises.

24 Becoming Familiar with your Computer Login Login Locate the Java compiler Locate the Java compiler Understand files and folders Understand files and folders Write a simple program (later) Write a simple program (later) Save your work Save your work

25 A Console Window

26 An Integrated Development Environment Figure 9: An Integrated Development Environment

27 A simple program  public class ClassName  public static void main(String[] args)  // comment  Method call object.methodName(parameters)  System class  System.out object  println method

28 File Hello.java 1public class Hello 2{ 3public static void main(String[] args) 4{ 5// display a greeting in the console window 6System.out.println("Hello, World!"); 7} 8} Output: Output: Hello, World! Hello, World!

29 A Simple Program Figure 13: Calling a Method System Class System.out Object println Method public class ClassName public static void main(String[] args) // comment Method call

30 Self Check 7. How would you modify the HelloTester program to print the words "Hello," and "World!" on two lines? Ans: 8. Would the program continue to work if you omitted the line starting with // ? Ans: Yes–the line starting with // is a comment, intended for human readers. The compiler ignores comments. System.out.println("Hello,"); System.out.println("World");

31 Self Check cont… 9. What does the following set of statements print? Ans: The printout is My lucky number is12. (It would be a good idea to add a space after the is. ) System.out.print("My lucky number is"); System.out.println(3 + 4 + 5);

32 Errors  Syntax errors System.ouch.print("..."); System.out.print("Hello);  Detected by the compiler  Logic errors System.out.print("Helop");  Detected (hopefully) through testing

33 Self Check 10. Suppose you omit the // characters from the HelloTester.java program but not the remainder of the comment. Will you get a compile-time error or a run-time error? Ans: A compile-time error. The compiler will not know what to do with the word display. 11. How can you find logic errors in a program? Ans: You need to run the program and observe its behavior.

34 From Source Code to Running Program

35 The Edit-Compile-Test Loop

36 CLASSWORK/HOMEWORK! R1.11 Use the Hello.java program to create different syntax errors. Record these errors. Then use the program to create a logic error. Describe the error you created. R1.11 Use the Hello.java program to create different syntax errors. Record these errors. Then use the program to create a logic error. Describe the error you created. Do Exercises p 30 – 31 P1.1, P1.2, P1.4 - P1.7 Do Exercises p 30 – 31 P1.1, P1.2, P1.4 - P1.7 At home Read sections 1.7 through 1.8 taking notes (pp 23-27) At home Read sections 1.7 through 1.8 taking notes (pp 23-27) On p 29 do review exercises R1.4 – 1.6, R1.10, and R1.12 to hand in. On p 29 do review exercises R1.4 – 1.6, R1.10, and R1.12 to hand in. Project 1.1 Project 1.1


Download ppt "CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture."

Similar presentations


Ads by Google