CS 50 Homework 6 (Section 1 — Prof. Marshall)

Due by class time Tuesday, March 5
  1. Programming Exercise P6.4 (page 263). Name your applet program and HTML file "RandomWalk". You should use a 30 x 30 grid instead of 10 x 10 as suggested in the book. Files to submit: RandomWalk.java, RandomWalk.html

  2. Programming Exercise P7.5 (page 308). Name your program "TestDistance". Put all methods (distance, main, and any helper methods) in the TestDistance class. You don't need to make this program an applet. Hint: the distance between points (x1, y1) and (x2, y2) is given by the formula
    Files to submit: TestDistance.java

  3. Programming Exercises P7.10 and P7.12 (pages 309-310). Name your program "ZipCode". The ZipCode class must contain the following static methods:

    Your encodeZip and decodeZip methods should take strings representing zip codes or bar codes and return strings representing bar codes or zip codes, respectively. For example:

    Use periods (.) for the half-bars instead of colons (:) as suggested in the book. Files to submit: ZipCode.java

EXTRA CREDIT PROBLEMS
Note: you should finish the other problems before attempting these.

  1. Programming Exercise P6.20 (page 268). Name your applet program and HTML file "Graph". Files to submit: Graph.java, Graph.html

  2. Programming Exercise P6.11 (page 265). Name your program "Flesch". You will need to read Productivity Hint 6.1 on page 248 in order to do this problem. Files to submit: Flesch.java


Turning in Your Homework

To turn in your homework, put the specified files into a single folder named Your Name HW 6 and drop this folder into the drop box. If you are an off-campus student, you may copy your folder to a CLEAN floppy disk (one containing no other files or folders), and hand this in at the beginning of class, instead of using the drop box.