CSC 172
Homework 1
Assigned Sept. 11, due Sept. 18, to be done in two-person teams
-
As you go, or when you're done, fill out a time log form in our
PSP package (click on "Input" under "Time Management Data").
For this assignment, there's probably not much purpose in keeping a
defect log or making an estimate in advance.
-
Copy the "Posn" version 5 BlueJ project into your own folder or
floppy-disk and make sure it works as is.
-
Modify the source code with a variety of intentional errors: misspelled
variable names, misspelled method names, misspelled type names, missing
left parenthesis, missing right parenthesis, extra parentheses, missing
semicolon in statement, missing or extra curly-braces, and anything else
you think up. For each one, press the "Compile" button and copy down
what error message you got. (Then un-do the error and make sure it
compiles successfully again before you try another error!) E-mail
me the list of error messages, along with what you did to cause each
one.
-
Copy the "FunWithStrings" BlueJ project into your own folder or
floppy-disk and make sure it works as is.
-
Write down a bunch of Java expressions and statements, predict
their results, and test them by inserting uses of them into the
"test" method of the "FunWithStrings" class (use "Posn" version 5 as a
model for writing such a "test" method). Your collection of examples should
include all of the following:
-
Data types: int, boolean, double, String.
-
Arithmetic Operators: +, -, *, /, %, =, <, <=, ==.
-
Built-in String methods (you may need to look up some of these in the on-line
documentation. Hint: these are methods for the String class,
which is part of the java.lang package.):
-
toUpperCase
-
toLowerCase
-
length
-
equals
-
compareTo
-
concat
-
substring
-
indexOf
-
Other built-in methods: System.out.println, System.out.print.
-
Statement types: declaration, assignment, and method-call.
How to turn this in: Once you've got all your examples in the "test"
method, compile the program, right-click on the "FunWithStrings" class
box, and select the "test()" method. It should create a terminal
window showing the output from your method. From the "Options" menu
in this terminal window, choose "Save to File..." and save the contents
of the window. Then send me an
e-mail, attaching this file and your modified FunWithStrings.java file.
The body of the e-mail should be a brief description of what you've learned
about these methods and operators, noting especially any results you got
that differed from what you expected.
Last modified: Monday, 31-Jan-00 10:23:56
Stephen Bloch / sbloch@adelphi.edu