| Java Programming Spring 2003 Homework #2 |
|   Course Syllabus   |   Java Programming Home   |   HW2 FAQ   |   Assignment   |   How to submit |
| Assignment |
This assignment involves the creation of a number of Java classes, each defined in it's own file. Each class should have a main() method so the class can be run.
IMPORTANT!!! : You have to use the class names specfied here, you can't make up your own names. Java class names are case sentitive. Note that by defining the class names, we are also defining the file names you will submit.
Class SumOfArgs |
Create a class named
SumOfArgs that will print out the sum of all integer
arguments found on the command line. Anything that is not an integer
should be skipped (should not contribute to the sum). Your progam
should print out only the sum (nothing else!). No error messages
can be printed out (no matter what the command line args look
like). Examples of what your class should do when run:
> java SumOfArgs 0 > java SumOfArgs 10 9 8 27 > java SumOfArgs hello dave 1 2 3 6 > java SumOfArgs Hello World 0 |
Class Substring |
Create a class named Substring that will expect the
first command line argument to be a string, and the second two command
line arguments to be integers, the first will be used as an index and
the second as a length. The output should be the subtring of
string starting at the index and of the specified length. Examples:
> java Substring Jello 1 3 ell > java Substring "Hello World" 0 5 Hello > java Substring OneTwoThree 5 1 o |
Notes: As you can see from the examples, an index of 0
refers to the first character in the string. To figure out how to
extract a substring from a String, check out the API documentation for
the class String which can be found in java.lang
Class StringCompare |
Create a class named StringCompare that will be passed
two strings on the command line. Your class should print "true" if the
two strings are identical when compared without regard to the case of
each character (case insensitive comparison). If the strings are not
identical (ignoring case), your class should print "false". No error
messages should be printed (no matter what, if anything, is specified
on the command line). The default output should be "false", so if no
strings are specified (or only one), your class should print "false".
> java StringCompare Hello Dave false > java StringCompare Hello hello true > java StringCompare Hello Hellow false > java StringCompare false |
Notes: You really need to get to know about the String class
to get this working! You need to be able to convert strings to all
lower (or upper case), and then you need to figure out how to compare
two strings. Once again, look at the Java documentation for the String
class in the java.lang section of the API docs.
| How to submit |
Submission of your homework is via email, the general idea is to send an email message with your files as attachments. There is an automated email submission system that will respond to your submission right away, so you will have a record that we got your file. For HW2 you should submit your .java files (one for each class).
All projects must be submitted via email to javaprog-submit@cs.rpi.edu.
The subject line of the submission message should contain a single
number '2' indicating the HW number. The body of your message should
include your full name (and anything else you want to tell us). Make
sure your email message includes your full name, we can't record your
grade unless we know your name (and the email address
joe222@yahoo.com doesn't mean anything to us!).
Don't send compiled code (class files)!
You can expect a return email indicating receipt of your project submission immediately. This receipt will include a list of all the files that were successfully extracted by the submission script - please look over the receipt carefully to make sure your submission worked.
Multiple Submissions: You can resubmit up to 10 times for each project, we will always grade the last submission received unless you tell us otherwise.