CSSE 221: Fundamentals of Software Development Honors

Programming assignment (due by Sunday, 9:00am)

Finish BigRational, as stated in the specification, being sure you have checked in your final, fully-documented copy to the repository.

Written homework to do before week 2 (due before beginning of class on Monday, Sept 11).

As usual, please bring hardcopy for written answers to class to hand in on Monday.
  1. Read chapter 9 and skim section 13.1 from Savitch. You might also find the discussion of the Object class at the end of chapter 7 useful.
  2. I want to compare two BigRationals, x and y, to see if they are equal value (intuitively, x == y).
    1. Write an expression for this using the compareTo() method.
    2. Write an expression for this using the equals() method.
    3. What is compared if I actually write (x == y)? (Hint, you saw this in Chapter 5.)
  3. For the sake of simplicity, on this question, you may ignore effects such as operating systen interrupts that may change the runtime slightly. (Focusing on the meaning of big-oh only.)
    1. A block of code is characterized as O(n) and runs in 23 milliseconds. If n is increased by a factor of 8, what is the new runtime of the code?
    2. A block of code is characterized as O(n2) and runs in 400 milliseconds. If n is increased by a factor of 3, what is the new runtime of the code?
  4. What combination of control structure(s) gives code that is O(n3)?
  5. How many times is the sum statement executed (in terms of n):
    for (int i = 0; i < n; i++) {
    
    	for (int j = 0; j < n; j++) {
    		sum++;
    	}
    	for (int j = 0; j < n; j++) {
    		sum++;
    	}
    }
    
    Exact answer = ______, giving an asymptotic answer of O( ______ ).
  6. Name at least 3 advantages of unit testing.
  7. Suppose a user of your program finds a bug. What action should you take beyond fixing the bug?
  8. Explain, in a one or two complete (i.e. grammatically correct) sentences IN YOUR OWN WORDS why it is *usually* better to field application errors without exceptions.
  9. Write the code for a method that does the following:

    Pass into the method a BigRational object. Evaluate the object to determine if it is equal to it's own absolute value. If it is, print the message "Good going", and terminate the program. If it is not, print the message "Not good going", and terminate the program. Regardless of the outcome of this test, print the message "Done" before terminating.

    Write this code twice: once using if-then-else block(s) to evaluate the data and handle a possible error, and once using a try-catch block to evaluate the data and handle a possible error.

    Note: This code would never be written using a try-catch block in a production environment; we do it here to make sure you understand important structures.

  10. Reminder that assistants are in Moench F217 from 7-9pm on Sunday through Thursday nights to help you.