Please send questions to
st10@humboldt.edu .
CIS 480 - Spring 2001
HW #1
Due: Wednesday, February 7, 2001, beginning of lab
Given that this is a second Java course, and given that it is an
elective, I like to try to give you a *little* more leeway in the
programming assignments, while still requiring that certain features
be "practiced". So, each program you are to write has minimum
standards, but you then take it from there. Some possibilities are
given for each program to get you started in getting ideas.
If you meet the minimum requirements below, that up to 90% credit. If
you do something interesting in these programs, that's how you can
get up to 100%. Note that the possibilities given below do count as
"interesting" in this sense.
1. Write a Java application that:
* uses command-line arguments
* does something different from the in-class examples
* name this application Hw1Num1.java
* (you are expected avoid run-time exceptions from
"incorrect" command-line arguments --- use try-catch
to avoid such exceptions, if necessary)
* some possibilities:
* repeat the arguments, one per line, in a different order
from that originally given (in reverse order, perhaps,
or in some sort of sorted order --- in order of length,
perhaps, or in lexicographic order, etc.)
* compute the average of all numeric arguments
given (and ignore any non-numeric arguments) ---
print the resulting average, or print a message saying
no average was possible if no numeric arguments are
given.
* have the first argument determine what to do
with the rest of the arguments --- if it is -g, print
a greeting including each of the subsequent arguments,
if it is -b, print a farewll message including each
of the subsequent arguments, etc. Otherwise, it does
some default action for each of the arguments.
2. Write a second, *different* Java application that:
* uses command-line arguments
* checks its arguments, and complains and exits if they
are not just right
* does something different from the in-class examples
* name this application Hw2Num2.java
* (you are expected avoid run-time exceptions from
"incorrect" command-line arguments --- use try-catch
to avoid such exceptions, if applicable)
* some possibilities:
* check that there are exactly two arguments,
that they are numeric, and then perform some computation
on them, outputting the result.
* check that there is exactly one argument, and
print it forward on one line, backward on the next,
and one letter per line (going "down", thus)
* checks that there are at least three arguments,
that they are numeric, and then prints them in
ascending order on one line, and in descending order
on the next.
Minimal style standards (to be added to, if necessary!)
* every Java source file should begin with at least
a small block comment describing the purpose of what
is within, and including your name. If you are modifying
existing code (such as an in-class example), you should
indicate that, also.
* programs are expected to have at least a few
descriptive internal comments
* neat, consistent indenting is required.
* reasonably-descriptive and non-misleading variable
names are expected.
Then, send two e-mails to st10@humboldt.edu as follows:
* each Subject: line should be the name of Java source
contained within that e-mail message (so, one will have
Subject: Hw1Num1.java, and the other will have
Subject: Hw1Num2.java)
* the *body* of each e-mail should contain the
Java source (that is, do NOT include it as an attachment!!!)
* please FIX the indenting in the Java source code
if it is ugly when placed in the e-mail body! (Source code
pasted from BlueJ sometimes requires such clean-up.)