Programming Assignment 04


Due: Week of Sep. 19 in lab


  1. Problem 1.3.11 on page 78 of your book. Name the file and program ch1sec3prob11.java. Worth 10pts. Do not output any values of 2^N. When using Math.log(N) immediately cast down to an int type.
    Examples:
  2. Problem 1.3.27 on page 81 of your book. Name the file and program ch1sec3prob27.java. Worth 20pts. Take N as a command-line argument.
    Examples:
  3. Write a program which takes a single String (no spaces) from standard input. First, your program should remove all duplicate letters (Hint: use substring() to decompose a string and concatenation to recompose it). Second, your program should reverse the String (Hint: convert the String to a char[] with toCharArray()). Last, output the modified string. Name the file and program ch1sec4prob00.java. Worth 30pts. You cannot use the Java class/utility StringBuilder. Also note that 'e' is NOT a duplicate of 'E'.
    Examples:
  4. Problem 1.4.30 on page 118 of your book. Name the file and program ch1sec4prob30.java. Worth 40pts. Take M, N, and p as command-line arguments in that order. Hint: you only need a single multidimensional array of booleans to solve this problem, the output is analysis of those booleans.
    Examples:
  5. Bonus. Problem 1.5.19 on page 157 of your book. Worth 10 pts. However, each way you improve the solution beyond the basic specification will earn you more points. Be sure to write comments in your program about how it is improved. Ideas include animating the drawing of the lines infinitely, making the lines have an artistic coloring, or allowing keyboard input to alter the probability p. Name your file and program ch1sec5prob19bonus.java.
    Examples: