Assignment 2, due Jan 29
Part of
the homework for CS:2820, Spring 2016
|
On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of lecture on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!
a) What is the name of the encryption system supported by this program. (Hint: Read the comments, and if you are not sure if this is a proper name for an encryption system, look it up in Wikipedia.) (0.5 points)
b)
The program uses some ugly code such as:
if ((c >= 'a') && (c <= 'z')) {
How would the program's behavior change if you wrote this code?
if (Character.isLowerCase(c)) {
(Hint: Google the official documentation for the Java
isLowerCase() predecate. If you use the right import
statement, you can leave off the Character. prefix.)
(0.5 points)
A simple programming problem: Translate the informal function definition given in Homework 1 into a Java method, and then write a program to call that method and print the successive values of its output. Here is an example of what the first few lines of your output should look like:
f(0)=0 f(1)=1 f(2)=1 f(3)=0 f(4)=-1
Handwritten code is sufficient, but you can be more assured that it works if you write a little Java program to call it for successive integer values.
Note that a complete, cleanly formatted solution requires fewer than 20 lines of code. You will be graded on clean formatting! Any java program can legally be written as one line of code, but it's not very readable if you do this. (1 point)
A question: What application processes the final category of comments? (Hint: The assigned reading in the textbook answers this question.)