Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.

Similar presentations


Presentation on theme: "COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis."— Presentation transcript:

1 COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis

2 What we’ll talk about today... 4 Brief overview of computers 4 Hardware and Software 4 What is programming? 4 Java 4 Algorithms

3 Computers 4 Basically “information processors” –Take info, do something to it, spit it out again 4 Digital –Store the information as numbers (“digits”) 4 Use the binary number system

4 Computers are made of 2 things 4 Hardware –The part you can see and touch –CPU, monitor, mouse, keyboard 4 Software –Information to tell the computer HOW to process information –OS, compiler, word processor, games, etc.

5 Hardware 4 CPU: Pentium (II/III), Alpha, Athlon 4 Memory: RAM, floppy disk, hard drive, CD 4 Input Devices: keyboard, mouse, data tablet 4 Output Devices: monitor, printer

6 Our view of the hardware Monitor Keyboard Main Memory Central Processing Unit Floppy Disk Hard Disk Secondary Memory

7 CPU 4 “Central Processing Unit” 4 Continuously does fetch-decode-execute fetch Retrieve an instruction from main memory decode Determine what the instruction is execute Carry out the instruction

8 Memory 4 An address is the name of a specific location in memory 4 Main Memory –run programs from here –fast, volatile 4 Secondary Memory –slow –permanent

9 This class is about Software 4 Operating System (OS) –Understands the hardware –Simplifies your interaction with the hardware –Controls starting/stopping applications 4 Applications –any software that isn’t the OS –what you will learn to write

10 Computer Languages 4 Machine Language –the form the CPU understands –strings of 1’s and 0’s 4 Assembly Language –people-friendly version of machine language 4 High-level languages –Java, C++, FORTRAN, COBOL, BASIC

11 Compilers and Interpreters 4 Both are ways to turn high-level languages into something the computer can execute 4 Compilers turn a source code file into an executable 4 Interpreters let you type the program into it and run it directly

12 Java is compiled and interpreted Java source code Machine code Java bytecode Java interpreter Bytecode compiler Java compiler

13 So what is programming? 4 Programming IS problem solving 4 Takes multiple steps: –understand what the problem is –find a solution (algorithm) for the problem –determine if the solution is correct –implement the solution –test the solution implementation

14 Implementation 4 Not any more important than other steps, but probably the one you know the least about 4 We are using Java

15 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); }

16 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } All programs have to be part of a class

17 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } Tells the computer where to start running the program

18 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } Braces indicate where different sections of the program begin and end

19 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } This tells the computer to print out “Hello!” (without quotes)

20 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } This indicates the end of a statement (one “step” in the program)

21 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } These are reserved words in Java. This means that Java uses them for a special purpose

22 Java Reserved Words abstract boolean break byte byvalue case cast catch char class const continue default do double else extends false final finally float for future generic goto if implements import inner instanceof int interface long native new null operator outer package private protected public rest return short static super switch synchronized this throw throws transient true try var void volatile while

23 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } These are identifiers. These are words chosen by a programmer as names for things.

24 Java Identifiers 4 Can include letters, digits, $, and _ 4 Must not start with a digit 4 They are case sensitive

25 Simple Java Program public class Simple { public static void main(String[] args) { System.out.println(“Hello!”); } Red identifiers were chosen by the author of this program Blue identifiers were chosen by another programmer.

26 Identifier guidelines 4 You want to choose descriptive identifiers –things like a, b, dm, tu are bad –things like lastValue, $cost are good 4 If multiple words, start each new word with a capital letter

27 Comments 4 You can insert comments in the code that are completely ignored by the compiler 4 two styles: –/* everything in here is a comment */ –// everything to the end of line is a comment 4 I was very bad and didn’t comment the program I showed before. Let’s fix that...

28 Simple Java Program /* a very simple Java program */ public class Simple { // prints a message to the user public static void main(String[] args) { System.out.println(“Hello!”); }

29 Algorithms 4 A step-by-step description of a solution to a problem 4 In some sense the computer is stupid and needs very explicit instructions

30 Homework 4 Read Ch. 1 (there are more specific instructions on the web page, but it’s ok if you just read the whole thing) 4 Write an algorithm for making a peanut butter and jelly sandwich


Download ppt "COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis."

Similar presentations


Ads by Google