CSC 172
Homework 1
Assigned Jan. 24, due Feb. 2, to be done in two-person teams
- Fill out the student survey on-line.
(You will not be graded on the answers, but you will be graded
on whether you do it or not.) Some of you may have filled out this
survey in a past semester; please fill it out again, as some of your
answers may have changed.
-
As you work on the programming part of the assignment,
keep track of all the error messages and other
defects you encounter using the
PSP forms
(click on "Input" under "Defect Removal Data").
(For this assignment, there's probably not much point in making a
"project plan". If you want to practice keeping time logs with
the PSP forms, you're welcome to, but they're not required for this assignment.)
-
Copy either the "Posn" folder (left over from last semester)
or the "Position" folder (a little more complete and up to date,
and with multiple versions so you can watch the growth of the program)
into your own folder or floppy-disk and make sure it works as is.
Both of these should be on the N: drive, in the CSC172_Spring_2001
folder.
If you're using "Position", work with the latest version (version 6).
-
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" folder 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:
Thu Jan 25 14:39:00 EST 2001
Stephen Bloch / sbloch@adelphi.edu