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):
- balance, which should be of type double
- rate, which should be of type double, representing the interest rate
in percent.
- 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:
-
Turn in a hardcopy printout of your java source file, which should be named
Compound.java, and and a printout of your test run.
Do not give me a copy
of the javadoc.html files.
-
All Java programs will be submitted by copying (or ftping) them to a specially
designated directory in AFS. Each person in the class has a subdirectory
which has the same name as your login
in
/afs/cu/class/cs242/fa10
Within this individual directory, create a subdirectory named p1.
Copy only the source file into this directory, not class files or javadoc
files.
So, for example, if your login name was smithjd then the file
Compound.java should be copied to
/afs/cu/class/cs242/fa10/smithjd/p1. These directories have permissions
set so that no one other than yourself and Prof. Lynch can read the files.
You may, of course, use whatever
operating system and compiler you wish to develop your code,
but the version you turn in, both hardcopy and the files submitted to AFS,
must compile and run under JDK installed in the Clarkson ITL (our lab room).
Your grade on the program will be based on:
- Correct execution. The program must follow all the specifications above.
The hardcopy of your program's execution should clearly
demonstrate that it does.
- Correct implementation. The program must follow all the design requirements above, in particular the class name
and the use of three variables of the types specified. At this point, we have
not learned about loops, so you don't need to implement one in your code.
- Readability of the code: commented and well-structured, so that it is
clear what the code is doing.
Use an accepted programming style. The style of the text
is fine. You should follow the Code Conventions
on matters like indentation and layout of your source code.
Whatever you do, be consistent.
- Appearance of the output. There isn't much you can do for this program,
but you should be able to line up the output fields nicely, and make the
messages understandable.
- Timely submission of your program. All hardcopy of the source and test files
must be turned in by the deadline.
Late programs will not be accepted. Printouts submitted electronically will be ignored.
-
Plagiarism (copying all or part of anyone else's
code) is a serious infraction of Clarkson regulations;
the penalty is a grade of 0 for the first infraction,
a final grade of F for further infractions.