CSE:141 Introduction to Programming Faculty of Computer Science, IBA BS-I (Spring 2010) Lecture 3.

Slides:



Advertisements
Similar presentations
In Review JAVA C++ GUIs - Windows Webopedia.com.
Advertisements

Overview of Programming and Problem Solving ROBERT REAVES.
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
Chapter 1 - An Introduction to Computers and Problem Solving
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
 Introduction to Programming History of programming.
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
University of Palestine software engineering department Introduction to data structures Introduction to java application instructor: Tasneem Darwish.
1 Chapter 1 Introduction to Object-Oriented Programming.
Introduction to Computer Programming CSC 1401: Introduction to Programming with Java Lecture 2 Wanda M. Kunkle.
Intro to Programming CST JavaScript. Objectives Define software Identify the different types of software Differentiate the different types of programming.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
CMSC 202 Computer Science II for Majors Fall 2009 Introduction.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Your Interactive Guide to the Digital World Discovering Computers 2012.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
High-Level Programming Languages: C++
CC111 Lec#5: Program Development 1 Program Development and Programming Languages Lecture 4 Reference :Understanding Computers Chapter 13.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Java Beserkers Group 4. Start of Java Development began on June of 1991 by a group of computer scientist at the Sun Mircrosystems Company Development.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
CHAPTER 1 Overview of Programming and Problem Solving.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
1 Overview of Programming and Problem Solving Chapter 1.
Introduction to C++ Programming Language
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
1 Programming Fundamentals How to Program in C++ How to Program in C++
Review, Pseudocode, Flow Charting, and Storyboarding.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Introduction to OOP CPS235: Introduction.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
1 Overview of Programming Principles of Computers.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Introduction to Computers Lesson 13A. home Computer Program A set of instructions or statements, also called code, to be carried out by the computer’s.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming C++
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Advanced Programming CS206 Introduction 1. Programming Language Code A programming language is a language that uses specially defined words, grammar,
Introduction to Programming 1 1 2Introduction to Java.
Your Interactive Guide to the Digital World Discovering Computers 2012 Chapter 13 Computer Programs and Programming Languages.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
Ch 1 - Introduction to Computers and Programming
“Under the hood”: Angry Birds Maze
CSCI-235 Micro-Computer Applications
Lecture 1: Introduction to JAVA
Java History Background information about Java and how the background affected it’s development 1.
Advanced Programming CS206
Introduction to Computers and Java
Algorithm and Ambiguity
Transition to Code Upsorn Praphamontripong CS 1111
Chapter 1 Introduction(1.1)
Ch 1 - Introduction to Computers and Programming
Algorithm and Ambiguity
Advanced Programming CS206
CS 1111 Introduction to Programming Spring 2019
ICT Gaming Lesson 2.
Presentation transcript:

CSE:141 Introduction to Programming Faculty of Computer Science, IBA BS-I (Spring 2010) Lecture 3

Lesson Plan Introduction to JAVA Algorithm using flow charts and Pseudocode. 2/13/20102Quratulain

History of Java In the early 1990's, putting intelligence into home appliances was thought to be the next "hot" technology. Examples of intelligent home appliances: – Coffee pots and lights that can be controlled by a computer's programs. – Televisions that can be controlled by an interactive television device's programs. Anticipating a strong market for such things, Sun Microsystems in 1991 funded a research project (code named Green) whose goal was to develop software for intelligent home appliances. An intelligent home appliance's intelligence comes from its embedded processor chips and the software that runs on the processor chips. Appliance processor chips change often because engineers continually find ways to make them smaller, less expensive, and more powerful. To handle the frequent turnover of new chips, appliance software must be extremely portable. Quratulain 2/13/20103

History of Java Originally, Sun planned to use C++ for its home appliance software, but they soon realized that C++ was less than ideal because it wasn't portable enough. Thus, rather than write C++ software and fight C++'s inherent deficiencies, Sun decided to develop a whole new programming language to handle its home appliance software needs. Their new language was originally named Oak (for the tree that was outside project leader James Gosling's window), but it was soon changed to Java. When the home appliance software work dried up, Java almost died before being released. Fortunately for Java, the World Wide Web exploded in popularity and Sun realized it could capitalize on that. Quratulain 2/13/20104

History of Java Web pages have to be very portable because they can be downloaded onto any type of computer. What's the standard language used for Web pages? Java programs are very portable and they're better than HTML in terms of providing user interaction capabilities. Java programs that are embedded in Web pages are called applets. Although applets still play a significant role in Java's current success, some of the other types of Java programs have surpassed applets in terms of popularity. In this course, we cover Standard Edition (SE) Java applications. They are Java programs that run on a standard computer – a desktop or a laptop, without the need of the Internet. Quratulain 2/13/20105

Portability A piece of software is portable if it can be used on many different types of computers. Object code is not very portable. As you know, object code is comprised of binary-format instructions. Those binary-format instructions are intimately tied to a particular type of computer. If you've got object code that was created on a type X computer, then the object code can run only on a type X computer. The Java solution to improve portability: – Java compilers don't compile all the way down to object code. Instead, they compile down to bytecode, which possesses the best features of both object code and source code: Like object code, bytecode uses a format that works closely with computer hardware, so it runs fast. Like source code, bytecode is generic, so it can be run on any type of computer. Quratulain 2/13/20106

Java Virtual Machine How can bytecode be run on any type of computer? As a Java program’s bytecode runs, the bytecode is translated into object code by the computer's bytecode interpreter program. The bytecode interpreter program is known as the Java Virtual Machine, or JVM for short. Quratulain 2/13/20107

8 Three C++ Program Stages other code from libraries, etc. other code from libraries, etc. written in machine language written in machine language written in machine language written in machine language written in C++ written in C++ via compilervia linker SOURCEOBJECT EXECUTABLE myprog.cppmyprog.objmyprog.exe

9 Java Portability Windows PC running JVM Windows PC running JVM Java Program Java Program via compiler via interpreter JVM SOURCEBYTECODE EXECUTABLES Payroll.javaPayroll.class Unix box running JVM Unix box running JVM Macintosh running JVM Macintosh running JVM Java Bytecode Java Bytecode

Java Program Data for Java Program Java Compiler Byte-Code Program Byte-Code Interpreter Machine-Language Instructions Computer Execution of Machine-Language Instructions Output of Java Program Java Virtual Machine Linker Previously Compiled Helper Programs Java Program Translation Including Linker 2/13/201010Quratulain

Object-Oriented Programming: OOP A design and programming technique Some terminology: – object - usually a person, place or thing (a noun) – method - an action performed by an object (a verb) – type or class - a category of similar objects (such as automobiles) Objects have both data and methods Objects of the same class have the same data elements and methods Objects send and receive messages to invoke actions 2/13/201011Quratulain

Example of an Object Class Data Items: – manufacturer’s name – model name – year made – color – number of doors – size of engine – etc. Methods: – Define data items (specify manufacturer’s name, model, year, etc.) – Change a data item (color, engine, etc.) – Display data items – Calculate cost – etc. Class: Automobile 2/13/201012Quratulain

13 Basic Control Structures in languages A sequence is a series of statements that executes one after another Selection (branch) executes different statements depending on certain conditions Loop (repetition) repeats statements while certain conditions are met A subprogram breaks the program into smaller units Asynchronous control handles events that originate outside our program, such as button clicks. 2/13/2010Quratulain

14 SEQUENCE Statement... 2/13/2010Quratulain

15 SELECTION (branch) IF Condition THEN Statement1 ELSE Statement2 Statement1 Statement Statement2 Condition... True False 2/13/2010Quratulain

16 LOOP (repetition) Statement... False True WHILE Condition DO Statement1 Condition 2/13/2010Quratulain

17 SUBPROGRAM (function) SUBPROGRAM1... SUBPROGRAM1 a meaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM 2/13/2010Quratulain

18 ASYNCHRONOUS CONTROL EVENT EVENTHANDLER a subprogram executed when an event occurs 2/13/2010Quratulain

19 Object-Oriented Programming A data type is the specification in a programming language of how information is represented as data and the operations that can be preformed on the data An object is a collection of data values and associated operations A class is a description of one or more like objects 2/13/2010Quratulain

20 More OOP Vocabulary Instantiation is the process of creating an object based on the description provided by a class A package is a collection of related classes 2/13/2010Quratulain

21 An Object of class Time Set Increment Write. Time OPERATIONS DATA Private data: hrs 8 mins 25 secs 42 2/13/2010Quratulain

Tools to document Algorithms There are two commonly used tools to help to document program logic (the algorithm). These are: – Flowcharts and Pseudocode. – Generally, flowcharts work well for small problems but Pseudocode is used for larger problems. 2/13/2010Quratulain22

Flow Chart Symbols Common symbols used in flowcharts 2/13/2010Quratulain23

Example A flowchart and equivalent Pseudocode to compute the interest on a loan 2/13/2010Quratulain24 Read NAME, BALANCE, RATE Compute INTEREST as BALANCE x RATE Write (Display) NAME and INTEREST Flow Chart Pseudocode

Example 2 The program computes the sum, average and product of three numbers. 2/13/2010Quratulain25 Read X, Y, Z Compute Sum (S) as X + Y + Z Compute Average (A) as S / 3 Compute Product (P) as X x Y x Z Write (Display) the Sum, Average and Product

Decisions (Switching logic) A step in an algorithm that leads to more than one possible continuation is called a decision. It is consists of two components: – a condition and – a goto command depending on the result of the condition test as follows. 2/13/2010Quratulain26 Condition (Question) "Answer" Is A == B? No Is B > A? Yes Is K <= 25? Yes Is SALES >= $ ? Yes

Decision Example In flowcharting, the diamond-shaped symbol is used to indicate a decision. Shows the flowchart for a program that reads two numbers and displays the numbers read in decreasing order 2/13/2010Quratulain27 Read A, B If A is less than B BIG = B SMALL = A else BIG = A SMALL = B Write (Display) BIG, SMALL

Loops Most programs involve repeating a series of instructions over and over until some event occurs. For example If we wish to read ten numbers and compute the average, we need a loop to count the number of numbers we have read. 2/13/2010Quratulain28

Loop (Cond.) 2/13/2010Quratulain29 set count to zero set total to zero read number while ( not end-of-data ) increment count by 1 total = total + number read number if ( count > 0 ) then average = total / count display average set count to zero set total to zero do read a number increment count by 1 total = total + number while ( not end-of-data ) if ( count > 0 ) then average = total / count display average Pre TestPost Test