Presentation is loading. Please wait.

Presentation is loading. Please wait.

Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.

Similar presentations


Presentation on theme: "Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities."— Presentation transcript:

1 Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities

2 Created by, Author Name, School Name—State Problem Solving PART 4

3 Created by, Author Name, School Name—State GET WITH THE PROGRAM Fundamental Concepts Expressed in JavaScript chapter 18

4 Copyright © 2003 Pearson Education, Inc. Slide 18-4 OVERVIEW: PROGRAMMING CONCEPTS > Programming is one implementation of an algorithm. > The audience for your program is the computer. > The language that you use will be a language that the computer can use.

5 Copyright © 2003 Pearson Education, Inc. Slide 18-5 Computer as audience > The computer is a non-intelligent tool. > The intelligence of a computer is what we humans have programmed into it. > It is a giant calculator…capable of doing many things but only upon the direction of the human “programmers”.

6 Copyright © 2003 Pearson Education, Inc. Slide 18-6 The language we use to express an algorithm must be precise. > Take the semester GPA example from last time. > It was necessary that the instructions be clear. Labels for each data element help. > Individual steps help. > Saying what totals should be stored where helps.

7 Copyright © 2003 Pearson Education, Inc. Slide 18-7 This algorithm > involves storing data (write down the number of credit hours…) > involves repetition > involves calculation (sum/average)

8 Copyright © 2003 Pearson Education, Inc. Slide 18-8 Algorithmic structures Algorithmic structure — Sequencing — Decision — Iteration — Abstraction Program structure — Order of statements — If statement — Loops — Functions

9 Copyright © 2003 Pearson Education, Inc. Slide 18-9 A computer program > is simply a set of statements that can be executed on the computer. > Source file – the file containing the statements written in a computer language. > Object file (executable file) – the file containing the machine language to run the program.

10 Copyright © 2003 Pearson Education, Inc. Slide 18-10 Languages > Some languages require a compilation step. — Compilation checks the source file for errors — If no errors, the compiler builds a machine language file. > Java has three steps — Compilation checks the source file for errors — If no errors, the compiler builds a “byte code” file. — Upon execution of the program, an interpreter converts the byte code to machine specific code. > Other languages use an interpreter to convert the code into machine language at “run time”.

11 Copyright © 2003 Pearson Education, Inc. Slide 18-11 So how do we express algorithms in a programming language? > JavaScript is a “language” developed by Netscape that allows us to embed programs into web pages. > JavaScript is a scripting language that is interpreted by the web browsers. > It is object oriented and event driven. In other words, the code allows the program to “react” to actions by the user. Programs consist of manipulating objects or building blocks of code written by others.

12 Copyright © 2003 Pearson Education, Inc. Slide 18-12 JavaScript > JavaScript works with any web browser. > The JavaScript programs we will work with will work within the context of an HTML page, but JavaScript may be used by itself.

13 Copyright © 2003 Pearson Education, Inc. Slide 18-13 Syntax > Syntax are the rules that govern the language. > Syntax rules tell us what is a legal expression or statement in the language and what cannot be interpreted. > We will be learning the syntax of JavaScript over the next few weeks and learning how to express our algorithms in that language.

14 Copyright © 2003 Pearson Education, Inc. Slide 18-14 Some other program structures > Containers – variables, constants, and literals contain values. Variables are designed to be reusable containers…we can change the contents of the variable container any time. > Assignment – putting a new value into a container > Calculations – perform some operation with a resulting value.

15 Copyright © 2003 Pearson Education, Inc. Slide 18-15 Some basic syntax in JavaScript > Variable declaration: var variableName; > Assignment: variableName = value; > Decision: if (logical expression) action; > Operation: + - / * > See sample program on page 492

16 Copyright © 2003 Pearson Education, Inc. Slide 18-16 Let’s look at these in more detail > Let’s look at the Bean Counter program > Execute the program — Sticky notes are the containers used — Write name of container in ink — Write contents in pencil (since they are variables and they can change) — Go line by line — I will provide input — What is your final price?

17 Copyright © 2003 Pearson Education, Inc. Slide 18-17 A VARIABLE DECLARATION STATEMENT > var (reserved word or key word) – alerts interpreter that a variable declaration is coming. > identifier or variable name — begin with any letter — may contain letters and/or digits — may use _ to separate words in an identifier — may contain no spaces (this is different from Access) — are case sensitive – total is different than Total. > Variable names should begin with a small letter. > var total, subTotal; <termination symbol for the statement is a semi-colon.

18 Copyright © 2003 Pearson Education, Inc. Slide 18-18 Declarations > All variables in a program must be declared before use. > When declared, a variable does not have a value. > Initialization is the process of assigning a variable its first value. > Variables may be initialized when declared, but it is often better practice to separate the two statements.

19 Copyright © 2003 Pearson Education, Inc. Slide 18-19 Example > var total = 0; > var total = 0, tax_rate =.05; > var total; > total = 0;

20 Copyright © 2003 Pearson Education, Inc. Slide 18-20 THREE BASIC DATA TYPES OF JAVASCRIPT > Rules for Writing Numbers — numbers are written without special symbols — numbers do allow – and. — scientific notation is also allowed 6.2 e+2 (e is times 10 to the power of 2) or 620. — JavaScript does not differentiate between integers and rational numbers. > Strings – “this is a String” > Boolean Values - true and false

21 Copyright © 2003 Pearson Education, Inc. Slide 18-21 Strings > Strings represent text data > Strings include any characters found in the character set. > String literals are expressed with double quotes surrounding them. (use double quotes(“), but single quotes(‘) will work as well). Quotes must be paired. > A literal just means something whose value is exactly what you see in the program. > var name = “Nancy Harris”; > A string with no characters in it is called the empty string.

22 Copyright © 2003 Pearson Education, Inc. Slide 18-22 Boolean values > This is a type that allows only two values, true or false. > Boolean values are used in decisions. > A condition or question may be either true or false. > Is it raining? Yes or No (True or False) > Remember one of our history figures, George Boole. These types of data are named for him.

23 Copyright © 2003 Pearson Education, Inc. Slide 18-23 THE ASSIGNMENT STATEMENT > Assignment Symbol > Interpreting an Assignment Statement > Three Key Points about Assignment

24 Copyright © 2003 Pearson Education, Inc. Slide 18-24 AN EXPRESSION AND ITS SYNTAX > Arithmetic Operators - +, -, /, * > Relational Operators - >, =, <=, ==, != > Logical Operators ||, &&, ! > + - concatenation

25 Copyright © 2003 Pearson Education, Inc. Slide 18-25 A CONDITIONAL STATEMENT > if Statements and Their Flow of Control > Compound Statements > if/else Statements > Nested if/else Statements

26 Copyright © 2003 Pearson Education, Inc. Slide 18-26 SUMMARY


Download ppt "Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities."

Similar presentations


Ads by Google