CS 110 Fundamentals of Computing
Homework Assignment 4
Bolker and Rodriguez
Spring 2004

Due date: Thursday, February 26, when labs close.

  1. JOI Exercise 3-9. Play with shapes. (Answer in memo.txt of course.)

    Important note When you use Internet Explorere to look for the downloadable code for Box.java on the web page at http://www.cs.umb.edu/joi/latest-joi-cd/joi/3/shapes/Box.java you will find it garbled. IE has decided (incorrectly) that the page is html, not java source code, because there is a little bit of html markup in the javadoc. This is not an error in JOI code, but it's still our responsibility to make the code available to you. The link http://www.cs.umb.edu/cs110/hw4/Box.java will work correctly.

    The original link will work with Netscape. Only IE is trying to guess what we meant, and has guessed wrong.

    The original link will also work in IE if you right-click on it and select "save target as..." from the drop down menu.unfortunately this wont work on the lab computers since they have right click disabled. (Thanks to Sean Marnell.)

    We're thinking about a fix for this problem. We doubt that we could convince Microsoft to change IE for us.

  2. JOI Exercise 3-12. this .

  3. JOI Exercise 3-16. Class VLine . You may skip the last paragraph ("Modify the DemoShapes ...").

  4. JOI Exercise 3-17. Class Frame. You may skip the paragraph ("Modify the DemoShapes ...").

  5. JOI Exercise 3-27. Class Exponentiate . Be sure to spell "Exponentiate" correctly!

    To write this program you will have to use BigIntegers, not ints. You can't add two BigInteger objects with the + operator - you do that by sending messages. The BigInteger API will show you how.

  6. Optional. JOI Exercise 3-23. Graphing linear equations. If you do this problem be sure to discuss it in your memo so we grade it.

    Subject: Exponentiate
    Date: Mon, 23 Feb 2004 13:41:22 -0500 (EST)
    
    Positive integer exponents only. 
    
    There is a BigDecimal class you could try if you wanted to deal with
    negative exponents, but I haven't asked for that.
    
    Good question.
    
     > From: a classmate
     > To: 
     > Subject: Exponentiate
     > Date: Mon, 23 Feb 2004 13:15:39 -0500
     > 
     > Hello Dr. Bolker,
     > Will Exponentiate be expected to work with negative exponent values; for
     > example 2^(-10)
     > 
     > I ask only because, if I understand correctly BigInteger will handle decimal
     > values no better than int, and therefore we will have no way of handling the
     > computation/answer to such a problem.
     > 
     > Thank you,
    
    
    From: Ethan Bolker 
    To: eb@cs.umb.edu
    Subject: Exponentiate
    Date: Tue, 24 Feb 2004 15:24:21 -0500 (EST)
    
    Several people have asked about how to mix int and BigInteger values
    when computing the required power. 
    
    There is enough information in the Exercise in JOI and the BigInteger
    javadoc to answer this question.
    
    Your program should no error checking (we will learn about that in
    Chapter 7). If the user enters 0 or a negative number for the base or
    the exponent the program might work and it might not. Whatever happens
    is fine as long as it produces the correct answers when both are
    positive.
    
    You should test those other values and discuss (in your memo) what happens.