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)
? :
) 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.
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.)
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).