This website is preserved for historical and scholarly reference and is no longer actively maintained.
Homework Assignments
Fall 1997
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 Wednesday, Sept. 3) Exercise R 1.16:
Using any word processor, present the calculations in a typed table in the style of the table at the top of page 32. All lines of the table until a zero balance is reached are to be included. Also type a complete sentence containing the answer to the question "After how many years is the account depleted?" Give this answer to the nearest tenth of a year.
#2 (due Friday, Sept. 5) Exercise P 2.12 on page 81
("Write a program that reads a number greater than or equal to 1000 from the user and prints it out with a comma ... ") Turn in a printout of your code. Be sure that you full name, date, and statement of the problem are included as comments. Assignment will be graded on correctness, alignment of code, use of white space, inclusion of required comments, and general overal quality.
#3 (due Monday, Sept. 8)
Turn in a typed (on a word processor) list of your grades through Quiz 5 (You may include grades after Quiz 5 if you wish.) Together with the average (do not drop any grades for this average) of all grades listed, an assessment of your progress in learning the course material, and, if your average is below 7.0, a plan for improving your average.
#4 (due Wednesday, Sept. 10) Exercise P 3.14 on page 129.
Turn in a printout of your program. Refer to the requirements of Homework 2 and follow style guidelines given in the text.
#5 (due Friday, Sept. 12) Exercise P3.16 on page 129.
("Write a graphics program that draws a clock face with the current time.") Turn in a printout of your program. Refer to the requirements of Homework 2 and the style used in the text.
#6 (due Monday, Sept. 15) Exercise P3.15 on page 129.
("Write a graphics program that asks the user to enter four data values. Then draw a pie chart showing the data values.") Turn in a printout of your program. Refer to the requirements of Homework 2 and the style used in the text.
#7 (due Wednesday, Sept. 17) Exercise P 4.10 on page 174.
("Write a program that translates a letter grade into a number grade. Letter grades are A B C D F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F-. A + increases the numeric value by 0.3, a - decreases it by 0.3. However, an A+ has value 4.0.)
#8 (due Friday, Sept. 19) Exercise P 4.6 on page 174.
("Write a program that reads in three floating-point numbers and prints the largest of the three inputs. ")
#9 (due Wednesday, Sept.24) Exercise P 4.11 on page 174.
("Write a program that translates a number between 0 and 4 into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B-. Break ties in favor of the better grade; for example 2.85 should be a B.")
#10. (due Friday, Sept. 26) Turn in a typed (on a word processor) list of your quiz grades through Quiz 13 and list of your homework grades through Homework 7. List the quiz grades and the homework grades separately. (You may include additional quiz and homework grades if you wish.) Compute (1) an average of quiz grades, (2) an average of homework grades, and (3) an overall average of quiz and homework grades together. Since homework and quiz grades receive equal weight, the overall average will be (sum of quiz grades + sum of homework grades) / (number of quiz grades + number of homework grades). For this assignment, do not drop any grades.
Write an assessment of your progress in learning the course material, and, if your average is below 7.0, a plan for improving your average.
As in the previous assignment, label everything.
#12 (due Friday, Oct. 3) Exercise P 4.12 on page 174.
("Roman numbers. Write a program that converts a positive integer into the Roman number system. ...)
Additional requirements:
Include four functions as follows.
A function named onesDigit receives an integer in the range 0 .. 9 and returns a Roman numeral as a string (0 returns "", 1 returns "I", etc.).
A function named tensDigit receives an integer in the range 0 .. 9 and returns a Roman numeral as a string (1 returns "X", 2 returns "XX", ..., 9 returns "XC").
A function named hundredsDigit receives an integer in the range 0 .. 9 and returns a Roman numeral as a string (1 returns "C", 2 returns "CC", ..., 9 returns "CM").
A function named thousandsDigit receives an integer in the range 0 .. 3 and returns a Roman numeral as a string (1 returns "M", ...).
Use a while loop to read year numbers until a negative input is read. Be sure to inform the user that entering a negative number terminates the program.
#13 (due Wednesday, Oct. 8) Exercise P 5.2 on page 225
("Write a procedure sort3(int a, int b, int c) that prints three inputs in sorted order.")
#14 (due Friday, Oct. 10) Exercise P 6.13 on page 286.
(Prime numbers. Write a program that prompts the user for an integer and then prints out all prime numbers up to that integer. ... )
#15 (due Wednesday, Oct. 15) Exercise P 8.4 on page 364.
First type in and compile the interface given to you in class. Then, one by one, expand each method of class Account, using the method in the main program.
Use print statements in the main program to test that your class methods are working correctly.
Be sure to add initial comments to all procedures and functions. Add other comments as necessary.
#16 (due Friday, Oct. 24) Exercise P 8.14 on page 365.
("Define a class Country that stores the name of the country, its population, and its area. ...")
#17 (due Monday, Oct. 27) On page 413, Exercises R 9.1, R 9.3, R 9.4, R 9.5, and (on page 414) R 9.8.
This homework is to be TYPED. Handwritten will not be accepted. This homework may be done in groups and one copy turned in for each group, giving names of everyone in group. You may type these assignments into a java program and compile and run them, but having a running program is not required. (Having a running program is, however, the best way to check your answers.)
#18 (due Wednesday, Oct. 29)
Write a loop that fills an integer array v with 10 random numbers between 1 and 100. A random number generator is found on pages 262-265. Using a for-statement print the array in the order v[0], v[1], v[2], ..., v[9]. Then, using another for-statement, print the array in the order v[9], v[8], v[7], ..., v[0].
#19 (due Friday, Oct. 31) On page 415, Exercise P 9.3
Write a procedure reverse that reverses the sequence of elements in an array. ...
#20 (due Monday, Nov. 3)
After reading page 91 - 92 of Kallman and Grillo "My name is Esther Gooch. Three months ago I was employed as an adult education teacher for ..."
complete steps 1A (List the relevant facts), 1B (Which of these raises an ethical issue? Why? What is the potential for resulting harm?), and 1C (List the stakeholders).
All work must be typed.
All work must be done in groups of three or more people. Turn in one paper with the names of all group members.
#21 (due Wednesday, Nov. 5) On page 415, Exercise P 9.4
Write a function
int [ ] append ( int [ ] a, int [ ] b )
that appends one array after another. ...
#22 (due Friday, Nov. 7) On page 415, Exercise P 9.6
Write a function
int [ ] mergeSorted ( int [ ] a, int [ ] b )
that merges two sorted arrays, producing a new sorted array. ...
#23 (due Monday, Nov. 10)
Run Program SortTime.java (page 480 - 481) for n = 1000, 2000, 3000, ..., 10000. Record the times and plot a graph of n versus time. On the same paper, plot time = c(n*n). You should choose c so that the plot of time=c(n*n) can be easily compared to the plot of time versus array size. Turn in a table of the data values from running the program (similar to the table on the bottom of page 481) and the graph.
#24 (due Monday, Nov. 17)
Design a class Rectangle. Summaries of methods available for the classes Point, Circle, Line, and Message are given on page 105. Your class Rectangle is to be a graphics class and have the standard methods for the graphics classes given in Chapter 3 of the text. The program should be documented as the example of class documentation handed out in class.
#25 (due Friday, Nov. 21)
Answer the Step III questions (Analyzing the ethicality of both alternatives
in Step II). Use the Step II statement handed out in class. Start with
A. If action in Step II is done, who, if anyone, will be harmed?" and
continue through "P. Which alternative is preferable, N or O?"
For more information on Exceptions look up Exceptions in the index (p. 617).
This assignment may be done in groups and one homework turned in
for each group.
#26 (due Monday, Nov. 24)
Replace your Rectangle class with the subclass Rectangle that extends class Point.
Optional Assignments will contribute points to your homework sum, but do not add anything to the divisor.
Optional Assignment #1: due Wednesday, Nov. 26 (10 pts.)
Remember Homework #9: Exercise P 4.11 on page 174. Redo this homework using throw and catch if a number less than zero or greater than 4 is used. (See catch on pages 214 and 430.) Please turn in both program and printout.
Optional Assignment #2: due Wednesday, Dec. 3 (20 pts.)
Follow the instructions for the game show problem handed out in class. Please turn in both program and printout.