Relative to the ``class notes'' section:
- Endeavor to include a relatively complete, faithful representation of the lectures.
- A daily summary, in the form of an abstraction, of the lecture of the day.
- Both...first do # 2 and then do # 1..
For the powerful ideas section:
Do a David Letterman style ``top 10 list'' of powerful ideas. Order them according to ``power.''
- Incremental programming is powerful because you do little by little.
- Problem decomposition - we use it to write programs.
- Parameters - write one method and use it many, many times.
- Variables
- Recursion
For each ``powerful idea'':
- Identify it and briefly describe if.
- Briefly say something about why you think it merits being called a powerful idea.
For the learning journal:
- Evaluate how the elements of this course fit into or don't fit into your life style.
- Discuss aspects of your learning about computer programming in this course...
- What was helpful?
- What was not helpful?
- What were the difficult areas?
- What were the easy areas?
- What was important?
- What was trivial?
More array stuff
Associated with each array is a public variable called length which stores the number of memory celss in the array.
TASK
Assume:
- a is an array of integer numbers.
- s is an array of Strings.
- both have been instantiated.
(1) Display all of the values in array a one per line.
for (int x = 0; x < a.length; x + +)
{
IO.println (a [x]);
}
|
OR
for (int x = 1; x < = a.length; x + +)
{
IO.println (a [x-1]);
}
|
(2) Add 10 to each element of array a.
for (int x = 0; x < a.length; x + +)
{
a [x] = a [x] + 10;
}
|
(3) Assign the largest value in array a to the variable mix which must be declared. Assume a has at least one element.
int max = a [0];
for (int x = 1; x < a.length; x + +)
{
if (a [x] > max)
{
max = a [x];
}
|
(4) Make a copy of array a called the copy c.
int c [];
c = new int [a.length];
for (int x = 0; x < a.length; x + +)
{
c [x] = a [x];
}
|
(5) Swap the first two values in array a.
DO NOT DO THIS!!!!
a [0] = a [1];
a [1] = a [0];
|
THIS IS THE REAL SOLUTION!!!!
int temp = a [0];
a [0] = a [1];
a [1] = temp;
|
PROBLEM
Read several (at least one) positive intergers and display all of the integers which are greater than their average value.
A solution which features the global procedural application architecture.
(1) The main method.
static public void main (String args [])
{
readAndStoreTheNumbers ();
computeTheAverage ();
displayTheNumbersAboveAverage ();
}
|
(2) The ``variables.''
static private int a [];
static private final int LIMIT = 1000;
static private double average;
static private int nrElements;
static private int number;
|
(3) Refine the methods.
static private void ReadAndStoreTheNumbers ()
{
a = new int [LIMIT];
nrElements = 0;
number = IO.read_int ();
while (number > 0)
{
a [nrElements] = number;
nrElements = nrElements + 1;
number = IO.read_int ();
}
}
|