CSSE 220 -- Object-oriented Software Development

Homework 1

  1. Programming
    1. Create an Eclipse project named HW1 with a file HW1.java, that contains a Java class called HW1 that implements the following two static methods. Note that each method must return a value. Neither method should print anything. To test these methods, you should write your own main() method that calls the prescribed methods with various arguments and prints the results so you can check the answers. When I test your program after you turn it in, my test code will not use your main() function, but it will call the other two functions, expecting exactly the signatures that I give you here.
      • public static int maxOfThree (int a, int b, int c)
        returns the largest number that is a value of one of the three parameters.
        You may find the ternary conditional operator (? :) helpful for this one (it can also be done with if)
      • public static int monthsToReach(double target, double monthlyDeposit, double annualInterestRate)

        A savings account starts with a zero balance. On the first day of each month, interest is calculated on the current balance and added to the account, based on 1/12 of the annual interest rate. Then monthlyDeposit is added to the account. This continues each month until the balance reaches or goes beyond target. This method returns the number of the months it takes for the balance to equal or exceed the value of target.

        For example, the call monthsToReach (30000, 500, 0.05) represents a monthly deposit of $500 and an annual interest rate of 5%, asking how long it will take to accumulate $30,000.00. The method returns  54 in this case (recall that it does not print anything).

      Estimated time: 30 minutes.

    2. If you have not already installed the Subclipse plug-in for Eclipse, you should do so. http://www.rose-hulman.edu/class/csse/resources/Subclipse/installation.htm.  If you took 120 in Spring, 2006 or later, you probably already have it. 
    3. Share your Eclipse project using Subclipse. The directions for checking in a project that you created outside of version control are slightly different than what you did in 120 (which was just to commit back modified versions of files we created in your repository):

      1. Right-click on your completed HW1 project.
      2. Choose Team > Share Project …
      3. Choose “create new repository location…”
      4. The url is http://svn.cs.rose-hulman.edu/repos/csse220-200830-yourusername
      5. You can accept the default folder name.
      6. Add a commit comment and click Finish. Wait for awhile while svn messages appear in the console.
      7. At the next window, confirm that all the files are checked (especially HW1.java) and click OK to complete it.
      8. You should see the yellow oval on the project and files within it.
      9. (If you make further changes, just commit them like you’re used to doing.)

    4. If you have any problems, we’ll troubleshoot them with you right before or at the start of class and it won’t be late
  2. Complete the assigned reading for the next session (see the course schedule). If there is something you do not understand, make note of it so you can ask about it.
    Estimated time: Textbook: 40 minutes.
  3. Glance at Exercises 1.1-1.12 of Weiss (pages 23-24).  If you aren't able to figure out the answers, perhaps you need to read more carefully.
  4. Complete the Angel quiz over this reading. You'll find this on the course Angel page, under Lessons → Assignments → Reading Quizzes → Quiz 1
    You may take the quiz multiple times. The last one taken is the one that counts! Estimated time (after reading the material): 20 minutes.

    One question on the Quiz asks, which section of Java in A Nutshell is called "Subclasses and Inheritance"? You should look this up on Safari Tech Books Online, as described in the Syllabus, before taking the quiz. The purpose for this question is to make sure everyone knows how to find the books there. Note that Logan Library's license for Safari only allows a few students at a time to access its books, and only one or two students at a time to access a specific book. To avoid long waits for other students, please log out of Safari as soon as you are done (by clicking the link near the top right of the page).