This website is preserved for historical and scholarly reference and is no longer actively maintained.
Homework Assignments
Fall 1998
Homework will be collected at the beginning of class on the date the homework is due. No homework will be accepted after the beginning of class.
Section 1 policy on collaboration on THESE assignments. You may talk with other students about any aspect of THESE assignments. You may also compare completed homework assignments. The object of these assignments is for you to learn some aspect of the course. Therefore, the more effort you put into these assignments and the less you allow others to do for you, the more you will learn.
The above policy does NOT apply to any other collected assignments!
#1 (due Monday, Aug. 31)
Write and test a program which will print your name, address, and phone number on the screen in the following format.
Jane Doe
204 College Avenue
Clemson, SC 29631
654-9876
Bring in a copy of the source code (i.e., Java code), and a hand-written (on the page with the source code) listing of what you typed to edit, compile, and run the program. If you are printing in our labs, you are required to use the line printer -- NOT THE LASER PRINTER!
#2 (due Friday, Sept. 4)
Bring in a copy of the source code for problem 1 in Further Exercises (page 83). Compile and run your program to be sure it works. For example, if the input read is "ABC", the program will list the following permutations:
ABC
ACB
BCA
BAC
CAB
CBA
Your program may list the permutations in any order you wish.
#3 (due Monday, Sept. 7)
Exercise #3 on page 96. Add a constructor to Laughter3 that doesn't take any arguments -- it just sets the instance variable to "ha". (Laughter 3 will now have two constructors.) Using a comment to explain what each method does, as illustrated on page 99 of the text, answer the question, "Why is such an overloaded constructor useful?" in a comment immediately preceding the constructor.
Place comment lines at the beginning of your homework assignment giving your name, CPSC 210 Section 1, the date the homework is due, and identification of the homework --
such as
// Jane Doe
// CPSC 210 Section 1
// September 7, 1998
// Exercise #3, page 96
// Add default constructor to class Laughter3.
#4 (due Wednesday, September 9)
Assignment to construct class Counter, handed out in class.
#5 (due Monday, September 14)
Exercise #3 on page 217: "Implement a date class whose constructor ..."
Turn in listing of the class, including a main function within the class which tests all constructors and methods. Use current style standards for class listing.
#6 (due Monday, September 21) Exercises 1 and 2 on page 305 as modified below.
Exercise 1. Add the method
complement (Set s)
to the Set class. The complement method creates a new Set object consisting of all elements of the instance (this) Set object that are not in Set s.
As used by an application program, the interface might look like
Set s3 = s1.complement(s2);
In the above example, s1.complement(s2) returns a reference to a new Set containing all elements that are in s1, but not in s2.
Exercise 2. Add the method
symmetricComplement (Set s)
to the Set class. The symmetricComplement method creates a new Set object consisting of all elements of the instance (this) Set object that are in one but not both of the Sets.
As used by an application program, the interface might look like
Set s4 = s1.symmetricComplement(s2);
In the above example, s1.symmetricComplement(s2) returns a reference to a new Set object consisting of all elements that are in either s1 or in s2, but not in both s1 and s2.
The code listing turned in should contain the entire class: i.e., the "Final Class Definition" from Section 8.11.7 of the text, together with your code for the above exercises. You may copy code from the text from
http://www.cs.clemson.edu/~cs101/public_html/arnowweiss/code
It will be necessary to add the lines
import java.io.*;
import java.util.*;
to the top of your program.
The listing you turn in should also contain either a main or testDriver that you used to test the new methods.
Use current style standards in this homework.
#8 Problem 4.22 on page 75 of Bailey (due Friday, Oct. 16)