CS242: Advanced Programming Concepts in JAVA

Fall 2010

Program 1

Due: 2:00 PM, Monday, 8/30/10

For this assignment you will create a simple Java program. You may work individually or with one partner on this program. It is also a good idea to use a browser to view the Java SE API documentation and accustom yourself to using this resource. This documentation can be easily downloaded (see the link in Online Resources) so that you have a local copy.

(a) This is a simple program to compute the balance in a bank account that compounds interest annually. The formula for computing the balance is:
balance_next_year = current_balance + current_balance*interest_rate

Your program should consist of one class named Compound.

Your program should have three variables (you don't have to use the same names, but use the types specified):

  1. balance, which should be of type double
  2. rate, which should be of type double, representing the interest rate in percent.
  3. year, which should be of type int, representing the current year.
Your program should print out five lines, the first line for the current year, and the next four lines for each of the next four years. Each line should state what the year is and what the balance for that year is. For example if the balance is $100.00, the rate is 5%, and the year is 2005, the output should be something like this:
The balance in year 2005 is $100.0
The balance in year 2006 is $105.0
The balance in year 2007 is $110.25
The balance in year 2008 is $115.7625
The balance in year 2009 is $121.550625
Of course, the actual balance should be rounded to the nearest cent, but we don't have to do that for now. And don't forget that percentages have to converted to real numbers.

(b) Add comment documentation to your program and use javadoc to extract the documentation into an HTML file. Include a javadoc comment for the class. The class comment should include your name and the date (use the @author tag).

The physical location of the javadoc comments is critical. A class comment must immediately precede the line containing the keyword class.

When you have commented your source files, run javadoc to create the .html files and view them in a browser of your choice.


What to submit:
Your grade on the program will be based on: