1 Purposes: Learn JAVA 1.What is programming languages 2.How to solve problems by computers 1.a CS major student, get a degree in BS 2.a programmer system manager project leader 3.a computer scientist is worthwhile and doable. Being
2 HardwareSoftware Theory 1800 AD Architecture 1945 AD What is Computer Science? Languages 1960 AD
3 Alan Turing ( ) – The Enigma The man who invented the computer Image from Turing Machines Turing Award: the Nobel Prize in CS
4 Said: “Turing Machines are human that compute.” “ In logic nothing is accidental ” Ludwig Wittgenstein ( ) Image from
5 Hardware Input deviceOutput device Central Processor Unit: Internal Storage Control Unit + Arithmetic-Logic Unit (ALU)
6 Software =16
7 A bit logical, Adder (half adder) 1 +) A B c S ABcS A B S c Adder ABAB
8 Full Adder CiCi A +)B CoCo S CiCi ABCoCo S A B S Co Full Adder Ci
9 4 bits Adder Full Adder Full Adder Full Adder Full Adder A B )
10 Logical Gates for an Adder (half adder) A +)B c S ABcS AND OR AND NOT B A S c Half-Adder
11 Software: 1.Operation systems 2.Applications XP, Unix, VAX Words Excel E.I. Hello Java Hello.java javac Hello.class (class loader) Eclipse, NetBean IDE, SunSun
12 IDE ( Integrated Development Environment ) 1.A customized plain text editor 2.Compiler 3.Loader 4.Debugging tool Java 2 Software Development Kit (J2SDK) Eclipse 1.notepad 2.javac hello.java 3.java hello
13 Solving a problems by computers = ? = sum1; sum1+2=sum2 sum2+3=sum3 sum3+4=sum4 sum4+5=sum5 sum5+6=sum sum = sum =1 1+2=3 3+3=6 6+4= = = =5050
14 Solving a problems by computers = sum1 sum1+2=sum2 sum2+3=sum3 sum3+4=sum4 sum4+5=sum5 sum5+6=sum sum = sum100 sum = 0 sum = sum+1 sum = sum+2 sum = sum+3 sum = sum +4 sum = sum sum = sum+100 computer can do the same thing again and again fast
15 Algorithm: a procedure of calculating (manipulate) data = ? sum = 0 sum = sum+1 sum = sum+2 sum = sum+3 sum = sum +4 sum = sum sum = sum+100 sum = 0; i = 1; while (i <= 100) do the following { sum = sum + i; i = i+1; } sum is the answer;
16 Graph Reachability G: (V,E) V: the set of vertices E: the set of edges V = {1,2,3,4,5,6,7} E = {(1,2), (1,3), (1,4) (3,6),(5,6), (5,7)} Is there a path from 1 to 6 in G? Is there a path from 1 to 7 in G?
17 Algorithm for Graph Reachability: Input G: (V,E), a,b; let S = {a}; mark a; while (s {}) do the following select one element from S; let it be x; remove x from S; let N = { y : (x,y) in E }; if b in N, say “yes” and stop; mark every b in X; set S = S union N; say “no”; Is there a path from a to b in G? Java C++ C Fortran Fortran90 Lisp Ada COBOL BASIC Pascal Polog
18 Pr8oblems Solutions cycle Problems System analyst, Project leader Algorithms Senior Programmers Programs in C++ (or any high level Programming Language) compiler Assembly Assembler Machine code linker Results Customers Programmers Syntax Semantics 95% (human) IDE 5% (computers)
19 Procedure vs Object To write a program is: To find a way to manipulate data -- We design procedures Procedure-Oriented Programming Statements + functions programs To find data to manipulate – We choose data (object) Object-Oriented Programming Classes + Objects programs (interfaces, methods, attributes…)
20 Classes: A class is a concept of something Vehicle 4 wheels, seat, engine, windows…… Truck ………… Sedan ………… SUV …………
21 Method & Attribute class: Method &Attribute Method: behaviors (operation, functionalities) Field (attribute): the properties the class
22 Objects Vehicle SUV Honda Pilot 011-JAV instantiation Class Object
23 A Java Program: // Fig. 2.1: Welcome1.java // Text-printing program. public class Welcome1 { // main method begins execution of Java application public static void main( String args[] ) { System.out.println( "Welcome to Java Programming!" ); } // end method main } // end class Welcome1 /********************************************************* *(C) Copyright by Deitel & Associates, Inc. and * * Prentice Hall. All Rights Reserved. * **********************************************************/