Full HTML for

Basic foilset Short Introduction to Kids on Basic Programming Concepts in Java

Given by Nancy McCracken at Sonia Kovalesky festival workshop (High School Girls) on October 23 1999. Foils prepared October 30 1999
Outside Index Summary of Material


See Project Page supporting Class
Introduction to Computers followed by Introduction to Java
Talk given at High School Girl Event by Nancy McCracken and based on Java Academy

Table of Contents for full HTML of Short Introduction to Kids on Basic Programming Concepts in Java

Denote Foils where Image Critical
Denote Foils where HTML is sufficient

1 Short Introduction to Basic Programming Concepts in Java
2 What is programming?
3 Variables and Types
4 Assignment
5 Arithmetic
6 Order of Execution
7 "For" Loops
8 Arrays
9 Using Array Values
10 Arrays and For Loops
11 "If" Statements
12 Graphics Concepts in Java Applets
13 Drawing an oval
14 Java Development Cycle

Outside Index Summary of Material



HTML version of Basic Foils prepared October 30 1999

Foil 1 Short Introduction to Basic Programming Concepts in Java

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
Nancy McCracken
NPAC at
Syracuse University
1999

HTML version of Basic Foils prepared October 30 1999

Foil 2 What is programming?

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
A computer follows a set of step-by-step instructions, computing with values that are stored in its memory.
These are simple instructions, like "add two numbers".
A programming language like Java lets you write more complicated instructions. The compiler translates them into ones the machine can compute.
instructions
memory

HTML version of Basic Foils prepared October 30 1999

Foil 3 Variables and Types

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
A variable is a name that you give to a place to store a value in memory. When you declare a variable name, you say what type the values will be.
Declare 3 variables of type integer: There are many other types:
int x;
int y;
int size;
Or all at once for variables
of the same type:
int x, y, size;
String s;
Font f;
Color c;

HTML version of Basic Foils prepared October 30 1999

Foil 4 Assignment

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
The way that you put a value into the space named by the variable is called assignment:
Note that this is not the same as "=" in math. You can say things like: which means take the old value of x, add 1, and store it back into x.
int x, y;
x = 8;
y = 2 * x;
Take the value on the right of
the "=" and store it into the place
named on the left.
x = x + 1;

HTML version of Basic Foils prepared October 30 1999

Foil 5 Arithmetic

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
On the previous page, we had an example:
Note that we can use numbers like 8 and arithmetic operators +, - , * and / just the same as in math (except that numbers can't get too big)
Strings are sequences of characters in quotes:
Values of other types are created with methods.
int x, y;
x = 8;
y = 2 * x;
String s;
s = "This is a string."

HTML version of Basic Foils prepared October 30 1999

Foil 6 Order of Execution

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
Also note that the statements on the previous page are computed in the order that you list them. This is true within each method. A Java program is a collection of methods - each is "called" to compute its statements.
public class MyApplet extends Applet
{ public void init ( )
{
/* statement1 */
/* statement2 */
. . .
/* last statement */
}
public void paint ( )
{ /* statements go here */ }
public void helpermethod ( )
{ /* statements go here */ }
}

HTML version of Basic Foils prepared October 30 1999

Foil 7 "For" Loops

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
A loop statement tells the computer to execute a set of instructions many times, and is controlled by the loop variable.
int sum, num;
num = 8;
sum = 0;
for ( int i = 0; i < num; i++ )
{
sum = sum + i;
}
repeat loop 8 times and
add 1 to i each time
The body of the loop is repeated. Values of i each time around the loop:
i is 0
i is 1
i is 2
. . .
i is 7
What is the value of sum at the end?

HTML version of Basic Foils prepared October 30 1999

Foil 8 Arrays

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
Sometimes you have a collection of values that you want to give one name. One way to do that in Java is to have an array.
To create an array like this, you must say what type the elements are (they must all be the same type) and how many there will be:
An array has a set of positions to store values. Each position is given an index number:
int numbers [ ] = new int [ 7 ] ;
String labels [ ] = new String [ 64 ] ;
0 1 2 3 4 5 6

HTML version of Basic Foils prepared October 30 1999

Foil 9 Using Array Values

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
To use an array value, you give the name of the array and the position number within [ ], and use it like any other variable.
int numbers [ ] = new int [ 7 ] ;
numbers [0] = 5 ;
numbers [1] = numbers [0] + 2 ;
String labels [ ] = new String [ 64 ];
labels [ 0 ] = "The first string label";
g.drawString ( labels [ 0 ], 10, 20 ) ;
Create the array
Assign position 0
Use position 0

HTML version of Basic Foils prepared October 30 1999

Foil 10 Arrays and For Loops

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
To assign or use all the elements of an array in order, a "for" loop is handy.
int max = 8;
int numbers [ ] = new int [ max ] ;
for ( int i = 0; i < numbers.length; i++ )
{
numbers [ i ]= i * 2;
}
0 1 2 3 4 5 6 7
0 2 4 6 8 10 12 14

HTML version of Basic Foils prepared October 30 1999

Foil 11 "If" Statements

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
This statement is also called a "conditional" statement. It tests a "condition" and if it's true, it executes the first set of statements, and if it's false, instead it executes a second set of statements.
if ( num == 0 )
{ y = 0; g.setColor ( Color.red ); }
else
{ y = 1; g.setColor ( Color.black ); }
if and else are keywords
The condition is in ( )s.
If the condition is true, execute these statements,
otherwise these.

HTML version of Basic Foils prepared October 30 1999

Foil 12 Graphics Concepts in Java Applets

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
One kind of Java program is an applet, which is a program that can run in (most) web browsers such as Netscape.
The name of the applet is given in an <APPLET> tag in an HTML file.
Think of a Java applet as a graphics window on which to draw text and other objects.
The graphics window has a particular width and height as specified in the <APPLET> tag
The origin is in the top left-hand corner of the graphics window: the x-coordinate increases from left to right, while the y-coordinate increases from top to bottom

HTML version of Basic Foils prepared October 30 1999

Foil 13 Drawing an oval

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
(0,0)
(width,0)
(0,height)
(width,height)
(x,y)
x
y
(x,y)
w
h
g.setColor ( purple );
g.fillOval ( x, y, w, h);

HTML version of Basic Foils prepared October 30 1999

Foil 14 Java Development Cycle

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 1999. *
Full HTML Index
Or your system may have some other way to specify compile and load in browser.

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Oct 30 1999