05-CH10-17 (1)
05-CH10-17 (1)
05-CH10-17 (1)
http://video.google.com/videoplay?docid=8760693941184809872#
14
Flowcharts
• Visual representation of sequence of
events to be performed in an algorithm
• Tool to review, capture and communicate
logic flow of a program
Flowcharts
1. All steps should be listed logical order
2. Be clear, neat and easy to flow
3. Usual direction flow is left to right or top to bottom
4. Flow lines: Used to connect steps
A. Start = 1 line out
B. End = 1 line in
C. Input, Output, Process = 1 line in and 1 line out
D. Decision = 1 line in, always 2 lines out
5. Brief statements (pseudocode) inside symbols
A. Pseudocode is a short, description statement for the
computer to accomplish
B. Non-standard and subjective
Flowchart
Algorithm (pseudocode)
1. Enter www.facebook.com into your browser. (I/O)
2. facebook login page loads (PROCESS)
3. facebook login page is displayed (I/O)
4. User enters ID and password(I/O)
5. ID and Password are validated (DECISION)
a. If not valid
1) Determine error (PROCESS)
2) Display Login Page with error message (I/O)
b. If valid
1) Find User’s Home Page (PROCESS)
2) Display User’s Home Page (I/O)
Flowchart
Algorithm (pseudocode)
1. Enter www.facebook.com into your
browser. (I/O)
2. facebook login page loads
(PROCESS)
3. facebook login page is displayed
(I/O)
4. User enters ID and password(I/O)
5. ID and Password are validated
(DECISION)
a. If not valid
1) Determine error (PROCESS)
2) Display Login Page with error
message (I/O)
b. If valid
1) Find User’s Home Page (PROCESS)
2) Display User’s Home Page (I/O)
Problems
CODING:
<script>
var fahrenheit, celcius;
fahrenheit = ????;
celcius = (fahrenheit - 32)* 5/9;
alert (celcius);
</script>
FtoC.html
2.Calculate pay given hours worked and pay per hour.
CODING:
<script>
var hours, payRate, totalPay;
hours = ????;
payrate = ???
totalPay = hours * payRate;
alert (totalPay);
</script>
pay1.html
2.Calculate pay given
hours worked and pay
per hour.
OVERTIME?????
Fundamental Concepts Expressed inJavaScript
(Chapter17)
CS170
Computer Applications for Business
JavaScript – Chapter17
• Programming Concepts • Expressions
• Names (including rules for • Conditionals
identifiers and case sensitivity), • Conditional Statements
values, and variables • Compound Statements
• Initialization and Declaration • An Expression and Its
• Data types: numbers, string Syntax
literals, Booleans (Three Basic • Keywords (reserved words
Data Types of JavaScript) – you do not have to
• Assignment Statements memorize all of them),
• Operators: Assignment, escape mechanisms
Arithmetic, Relational, Logical, • Embedding JS in HTML,
operator overload document.write(),
prompt() and alert()
Parts of HTMLCode/Webpage
<head>
<script>
// Place your JavaScript here
</script>
Script tags can go
</head>
in either the
<head>,
<body> <body>, or both
<script>
// Place your JavaScript here
</script>
</body>
Basic Syntax
• A program is simply a list of statements
• Case sensitive
first_name
Legal
Illegal starts with a number.
Legal
e f
area
Good Practice
Create Meaningful Identifiers for the following:
e height f width
area
area
Good Practice
Create Meaningful Identifiers for the following:
e blue_height f blue_width
area blue_area
Variable Declaration Statement
The var command declares/creates a variable
var age; age
var area;
var radius;
Can declare (optional) multiple variables at one
time, separated with commas
var area, radius; area radius