CSCI A201/A597

Lecture Notes 6

Spring 2000


Wrapping up Homework 1 Notes. Selecting and reporting the maximum value from a sequence of values. Command-line arguments. Introduction to the lab notes and to the element package.

Today we will discuss the following program:

public class FindMax {
    public static void main(String[] args) {
	int size = args.length; 
        int max = 0; 
	for (int i = 0; i < size; i++) { 
	    int number = Integer.parseInt(args[i]); 
            if (number > max) {
		max = number; 
	    } 
	}
	System.out.println("Max is: " + max); 
    }
}
The goal is to understand completely all of the elements that appear in this program, as well as how it works. Consider the following questions:

The answers to these questions are all simple variations on the program above. In class we will develop solutions (programs) for these questions. I will add the code that we will develop in class to these lecture notes after the class.

We are going to introduce a new primitive type in the process, to be able to compute with decimals, called double.

This should be wrapping up the notes for the homework assignment.

Next we will discuss the lab assignment (In-Lab #2). You will have to write a program and test several others that make use of the package (element) that is described in Chapter 2 of your text. Here now is a description of the program that you need to write.

See lab 3 notes for more details on that. In class I will only demo a prototype and take any questions that you may have.

Finally you will have to test a few programs on the floppies that will be distributed to you in the labs (which contain the packages that we need for this class). The programs will be demoed in class today. In lab we just want to make sure that you can use the packages distributed to you and for this part of the in-lab assignment you should turn in both the source code as well as the .class files.

See lab notes 3 for more details and the source code of the programs.

As mentioned the goal is to experiment with the programs and get exposed to the way they receive input and produce output. Next week we will try to understand them very well so that we can write other programs similar to them, or to enhance these very programs (making them more robust, or adding new functionality).


Last updated: January 27, 2000 by Adrian German