ISP 121 Algorithmsand Computer Programming. Why Know Simple Programming?  You can create powerful macros in Access / Excel / Word / ??? to manipulate.

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
CS107 Introduction to Computer Science Lecture 2.
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
Chapter 2: Algorithm Discovery and Design
Designing Algorithms February 2nd. Administrativia Lab assignments will be due every Monday Lab access –Searles 128: daily until 4pm unless class in progress.
CS107 Introduction to Computer Science Lecture 2.
Designing Algorithms Csci 107 Lecture 3. Designing algorithms Last time –Pseudocode –Algorithm: computing the sum 1+2+…+n –Gauss formula for 1+2+…+n Today.
Web Page Development Identify elements of a Web Page Start Notepad
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
CM143 - Web Week 2 Basic HTML. Links and Image Tags.
CIS101 Introduction to Computing Week 12 Spring 2004.
Chapter 2: Algorithm Discovery and Design
JavaScript Switch Statement. Switch JavaScript Switch Statement If you have a lot of conditions, you can use a switch statement instead of an if…elseif…
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
CSCI-100 Introduction to Computing Algorithms Part I.
Introduction to HTML. Topics HTML –What is HTML –Parts of an HTML Document –HTML Tags.
Adding JavaScript (<script tag>)
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
THE BIG PICTURE. How does JavaScript interact with the browser?
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
Chapter 4 JavaScript and Dynamic Web pages. Objectives Static Web pages Dynamic Web pages JavaScript Variables Assignments. JavaScript Functions –(prompt(“”,””)
XP 1 HTML Committed to Shaping the Next Generation of IT Experts. 01: Introduction to HTML.
Objective Static vs. Dynamic Web pages. Variables. Assignments. JavaScript Hierarchy of Objects JavaScript Functions (prompt(“”,””) Document.write(“”)
Just Enough HTML How to Create Basic HTML Documents.
HTML Hyper Text Markup Language. What is an HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup.
1 JavaScript 1. 2 Java vs. JavaScript Java –Is a high level programming language –Is platform independent –Runs on a standardized virtual machine.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
Introduction to Algorithms. What is Computer Science? Computer Science is the study of computers (??) This leaves aside the theoretical work in CS, which.
Chapter 23 - World Wide Web Documents (HTML) Introduction Display Hardware Varies A Browser Translates And Displays A Web Document A Consequence Of The.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
COMPUTERS AND ALGORITHMIC PROCESSES LSP 121. What Is An Algorithmic Process? An ordered series of steps that when applied to a problem produces a solution.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
1 JavaScript
1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 4 JavaScript and.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
CSCI-100 Introduction to Computing
CS 111 – Oct. 4 Web design –HTML –Javascript Commitment: –This week, read sections 4.3 – 4.5.
JavaScript, Fourth Edition
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
CIS 375—Web App Dev II JavaScript I. 2 Introduction to DTD JavaScript is a scripting language developed by ________. A scripting language is a lightweight.
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
In God we trust Learning Java Script. Java Script JavaScript is the scripting language of the Web! JavaScript is used in millions of Web pages to improve.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
ICS124 Session 9 Flowcharting 1. By the end of this section the student will be able to:  Name the three structures of the Structure Theorem  Identify.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
JavaScript JavaScript ( Condition and Loops ). Conditional Statements If Statement If...else Statement if (condition) { code to be executed if condition.
JavaScript 101 Lesson 6: Introduction to Functions.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Chapter 6: Conditional Statements and Loops
WEB PROGRAMMING JavaScript.
T. Jumana Abu Shmais – AOU - Riyadh
Algorithm Discovery and Design
Introduction to Algorithms and Programming
CS105 Introduction to Computer Concepts
Web Programming and Design
Presentation transcript:

ISP 121 Algorithmsand Computer Programming

Why Know Simple Programming?  You can create powerful macros in Access / Excel / Word / ??? to manipulate data  You can create interactive web pages, such as the DePaul QRC mapping tool  You can write simple programs to analyze data and write the next article exposing cheaters in your school district

What is an Algorithm?  Computers require precise instructions to perform an operation  The instructions cannot be ambiguous  An algorithm is an ordered sequence of instructions that is guaranteed to solve a specific problem

What is an Algorithm?  Algorithms consist of three basic types of operations or instructions: Sequential operations, e.g. Add 1 cup of butter; Subtract the amount of the check from the current account balance; Set the value of x to 1 Sequential operations, e.g. Add 1 cup of butter; Subtract the amount of the check from the current account balance; Set the value of x to 1 Conditional operations, e.g. If the mixture is too dry, then add ½ cup water; If the current account balance < 0, then account overdrawn Conditional operations, e.g. If the mixture is too dry, then add ½ cup water; If the current account balance < 0, then account overdrawn

What is an Algorithm?  Algorithms consist of three basic types of operations or instructions: Iterative operations, e.g. Repeat the previous two steps until the mixture has thickened; Repeat the following five steps until there are no more checks to be processed; Repeat steps 1,2 and 3 until the value of y is equal to +1 Iterative operations, e.g. Repeat the previous two steps until the mixture has thickened; Repeat the following five steps until there are no more checks to be processed; Repeat steps 1,2 and 3 until the value of y is equal to +1

Example  Add two values: How would you describe this operation to someone who has never seen carry arithmetic?

Average Miles Per Gallon (1)  Step 1: Get values for gallons used, starting mileage, ending mileage  Step 2: Set the value of distance driven to (ending mileage – starting mileage)  Step 3: Set the value of average miles per gallon to (distanced driven / gallons used)  Step 4: Print the value of average miles per gallon  Step 5: Stop

Average Miles Per Gallon(2)  Step 1: Get values for gallons used, starting mileage, ending mileage  Step 2: Set the value of distance driven to (ending mileage – starting mileage)  Step 3: Set the value of average miles per gallon to (distanced driven / gallons used)  Step 4: Print the value of average miles per gallon (more on next slide)

Average Miles Per Gallon(2)  Step 5: If average miles per gallon is greater than 25.0 then Print the message “You are getting good gas mileage.” Print the message “You are getting good gas mileage.”Else Print the message “You are NOT getting good gas mileage.” Print the message “You are NOT getting good gas mileage.”  Step 6: Stop

Average Miles Per Gallon (3)  Step 1: Repeat step 2 to step 8 until Response is No Step 2: Get values for gallons used, starting mileage, ending mileage Step 2: Get values for gallons used, starting mileage, ending mileage Step 3: Set the value of distance driven to (ending mileage – starting mileage) Step 3: Set the value of distance driven to (ending mileage – starting mileage) Step 4: Set the value of average miles per gallon to (distanced driven / gallons used) Step 4: Set the value of average miles per gallon to (distanced driven / gallons used) Step 5: Print the value of average miles per gallon Step 5: Print the value of average miles per gallon

Average Miles Per Gallon (3) Step 6: If average miles per gallon is greater than 25.0 then Step 6: If average miles per gallon is greater than 25.0 then Print the message “You are getting good gas mileage.”Print the message “You are getting good gas mileage.”Else Print the message “You are NOT getting good gas mileage.”Print the message “You are NOT getting good gas mileage.” Step 7: Print the message “Do you want to do this again, Yes or No?” Step 7: Print the message “Do you want to do this again, Yes or No?” Step 8: Get a value for Response from the user Step 8: Get a value for Response from the user  Step 9: Stop

HTML  Hyper-Text Markup Language  All web pages are made (to varying degrees) from HTML  Each HTML command tells the web browser what to do next, such as start a new paragraph, display an image, or insert a link

Begins every HTML document Begins the head section DePaul University Title that appears on browser title bar Ends the head section Begins the body section This is the first line. Text followed by line Break Start a new paragraph. Begins a new paragraph First Heading Level 1 heading (biggest) A second level heading Level 2 heading (little smaller) Inserts a horizontal rule (straight line) This line is bold. Bold text This line is italicized Italicized text Insert an image here DePaul CS Page Link to another web page Close the body section Ends every HTML document

JavaScript  JavaScript can be added to an HTML document to provide dynamic features  JavaScript can be added to the head or body of HTML code (but we will concentrate on examples in body), can assign values to variables, can perform decision statements, and can perform loop statements

Example - JavaScript in Body document.write("This message is written when the page loads")

Example - JavaScript in Body alert("This message is written inside an Alert box")

Example - Using a Variable var name name = prompt(“Please enter a name”) document.write(name)

Example - Using an If var d = new Date() var time = d.getHours() if (time < 12) { document.write(" Good morning ") } This example demonstrates the If statement. If the time on your browser is less than 12, you will get a "Good morning" greeting.

Example - Using an If…Else var d = new Date() var time = d.getHours() if (time < 12) { document.write(" Good morning ") } else { document.write(" Good afternoon ") } This example demonstrates the If...Else statement. If the time on your browser is less than 12, you will get a "Good morning" greeting. Otherwise you will get a "Good day" greeting.

Logical Operators  You can use the following logical operators in IF and WHILE statements ==!=>>=<<=

Example - Using a While to Count var i = 0 while (i <= 5) { document.write("The number is " + i) document.write(" ") i++ } Explanation: i equal to 0. While i is less than, or equal to, 5, the loop will continue to run. i will increase by 1 each time the loop runs.

Example - Using a While to Prompt var answer answer = prompt(“Do you understand quantum physics?”) while (answer == “no”) { document.write(“It is actually based on quantum things.") answer = prompt(“Now do you understand quantum physics?”) } document.write(“Congrats!”)