Presentation is loading. Please wait.

Presentation is loading. Please wait.

King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department Lecture 1 : Introduction.

Similar presentations


Presentation on theme: "King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department Lecture 1 : Introduction."— Presentation transcript:

1 King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department Lecture 1 : Introduction ICS102 - Introduction to computing

2 ICS102: Intro To Comp2 Components of a Personal Computer Questions : - what are the input devices ? - what are the output devices ?

3 ICS102: Intro To Comp3 A motherboard, provides the electrical connections by which the other components of the system communicate and hosts the central processing unit as well as other subsystems and devices. Motherboard

4 ICS102: Intro To Comp4 Motherboard example : Acer E360

5 ICS102: Intro To Comp5 CPU (Central Processing Unit) The Central Processing Unit (CPU) or processor is the portion of a computer system that carries out the instructions of a computer program and is the primary element carrying out the computer's functions. In an addition operation, the arithmetic logic unit (ALU) will be connected to a set of inputs and a set of outputs. The inputs provide the numbers to be added, and the outputs will contain the final sum. Example: (3 + 2) = 5 3 2 5

6 ICS102: Intro To Comp6 CPU memory –Registers –Cache Main memory (RAM): –Data has to be in main memory so that CPU can access it –Volatile: lost when program exits; computer shuts off Hard Disk, CD, etc. –Persistent –This is where you keep the data for long-term storage Memory  Memory refers to computer components, devices, and recording media that hold digital data used for computing for some interval of time.  There are mainly three types of memory :

7 ICS102: Intro To Comp7 Main Memory … 1002 1003 1004 1005 Cell Address Memory is divided into Many memory locations (cells) Each memory cell has a numeric address, which uniquely identifies it Each cell contains a data value, e.g. 22

8 ICS102: Intro To Comp8 Main Memory …

9 ICS102: Intro To Comp9 The word “Hello.” stored in 6 memory cells Main Memory …

10 ICS102: Intro To Comp10 Memory units : Bits and Bytes Bit -- most basic unit of memory –1 or 0, on or off 1 Byte = 8 bits In a computer, data values are stored as a sequence of bits 2 7 1004 1005 00000010 00000111 1004 1005

11 ICS102: Intro To Comp11 Program / CPU / Memory Interaction Example: –Input read a number from keyboard –Add 1 to it –Output it on screen Keyboard RAM 1 1 CPU RAM 2 Monitor 1 22

12 What is programming?

13 ICS102: Intro To Comp13 What is a program? A (software) program is a list of instructions intended to a computer The list must be ordered correctly A program has inputs and outputs Each instruction tells the computer to do something (an action, a calculation, a comparison)

14 ICS102: Intro To Comp14 Program Execution A program tells the CPU how to manipulate and/or move information Programming is about processing information –Take some input, manipulate it in some way, and produce a particular output Manipulation Inputs Outputs Program

15 ICS102: Intro To Comp15 Example 1 : Recipe for Scrambled Eggs Ingredients (Inputs) : two eggs, tablespoon of oil, salt Instructions (program): –Add oil to pan –Heat pan on stove –Crack eggs into pan –Add salt –Mix until light and flakey Output: scrambled eggs

16 ICS102: Intro To Comp16 Example 2 : Currency Exchange Input: –Amount –Source Currency –Desired Currency Instructions –Look up in table current exchange rate for the selected currencies –Calculate result as amount * exchange rate Output: result Task : convert an amount of money in some currency (e.g. US Dollars) to another one (e.g. Saudi Riyals).

17 ICS102: Intro To Comp17 Programming language A programming language is the language used to write programs A programming language employs a set of rules that dictate how the words and symbols can be put together to form valid program statements A programming language has a syntax and semantics There are several types of languages (functional, Object- Oriented, etc.) In this course we focus on Java programming language.

18 ICS102: Intro To Comp18 Java Java is a programming language originally developed by James Gosling at Sun Microsystems It was first released in 1995. The language derives much of its syntax from C and C++. But has a simpler object model and fewer low- level facilities than C and C++.

19 ICS102: Intro To Comp19 Why Java ? Currently, Java is the most popular language in the world !

20 ICS102: Intro To Comp20 Why Java ? 1.Simple Get started quickly 2.Concise Write less code 3.Object-oriented Better quality code 4.Portable Architecture neutral (write once run anywhere) 5.Secure More appropriate for Internet

21 ICS102: Intro To Comp21 Portability of Java Classical model : Java model :

22 ICS102: Intro To Comp22 Portability of Java Write once, run anywhere: Because applications written in the Java programming language are compiled into machine- independent bytecodes, they run consistently on any Java platform.

23 ICS102: Intro To Comp23 A Java Program A Java program consists of one or more classes A Java class consists of one or more methods A Java method consists of one or more statements A Java Program Java classes Java Methods

24 ICS102: Intro To Comp24 A Java Program A Java program resides in one or more files. The file name of a Java program has extension.java. One of the classes of a Java program is called the driver class. The name of the driver class must be the same as the name of its Java file. (Java is case sensitive. So EX1 is different from ex1.) The diver class must contain a method called main. The execution of Java program starts from the main method of the driver class.

25 ICS102: Intro To Comp25 Example of a Java Program

26 ICS102: Intro To Comp26 Example of a Java Program Class name Main method Instruction Class body

27 ICS102: Intro To Comp27 Example of a Java Program Also notice: Curly braces { }

28 ICS102: Intro To Comp28 Example of a Java Program Also notice: Parentheses ( ) Curly braces { }

29 ICS102: Intro To Comp29 Example of a Java Program Also notice: Parentheses ( ) Curly braces { } Square brackets [ ]

30 ICS102: Intro To Comp30 Example of a Java Program Also notice: A pair of braces { } define a block

31 ICS102: Intro To Comp31 Compiling and running a program Type in your program Save the program –Store all your files in one directory for now –Give the program the same name as the class Compile the program –this produces a.class file –Translates the program into something the computer can understand and execute (Java bytecode) Run the program Observe the result and adjust the program if necessary

32 ICS102: Intro To Comp32 Edit Text Editor Public class /* Adventure.java Public class Adven /* This program is an Arit */ public static void main /* Program statements g System.out.print(“Wel }

33 ICS102: Intro To Comp33 Compile - With Errors Adventure.java Public class Adven /* This program is an Arit */ public static void main /* Program statements g System.print(“Welcome } Compiler Errors and Warnings ------------------- Error : The method print( String) is undefined for Type System

34 ICS102: Intro To Comp34 Compile - Success Adventure.java Public class Adven /* This program is an Arit */ public static void main /* Program statements g System.out.print(“Wel } Compiler Adventure.class 001011010001011101 1011010001011101110 101000101110111010110100010 111011101011010001011101110 101101000101110111010110100 010111011100010111011101011 010001011101110010111011101 011010001011101110010111011 101011010001011101110010111 011101011010001011101110010 111011101011010001011101110 0101110

35 ICS102: Intro To Comp35 Run Program Welcome to the Arithm The date is Monday Sep What is your name?Fred Well Fred, after a day The cube appears to be You find a Green door, The door closes behind There is a feel of mat Adventure Fred 1

36 End


Download ppt "King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department Lecture 1 : Introduction."

Similar presentations


Ads by Google