CISC370-010 Project 1

Assigned: June 6, 2001, Due: June 13, 2001
Return on Investment (ROI) calculator
This project counts for 5% of the overall grade

Objective

The objective of this assignment is to become familiar with writing a java program. This program will be expanded upon in some of the assignments in the coming weeks.

The problem

When looking at retirement plans one typically sees things like:

Consider two hypothetical investors. By the time they were age 30, Matt and Nanette had each had $15,000 invested in an IRA earmarked for retirement. Nanette never made another contribution, but her investments returned 9% a year. Matt continued to contribute $2,000 each year, but was more conservative than Nanette and only achieved a 4% return each year. Although she had not made additional contributions, after 35 years, Nanette had accumulated more money in her account. How? ...

Or

Consider two hypothetical investors. Johnny and Susie both opened Roth IRAs. Johnny started investing for retirement at 45 and at retirement, in 20 years, will have $128,005. While Susie started investing when she was 24 and will have over a million dollars at retirement. Both of these situations assume yearly contributions of $2000 and an annual return of 10%.

The Assignment

There are many examples of these type of examples with retirement plans. What you will do in this project is write a Java application that takes the initial contribution, the addition per time period, the expected return and the number of periods. The period of time will typically be a year, but could be a month for the aggressive investor, or other time period.

The result will be a Java application that can be used to calculate a projected return on an investment. In future homeworks we will expand on this command line example to a GUI application and also an applet which could be on a web page.

Since this course is also about the WWW the example program to get the logic of what needs to be done is given in Perl. Perl is a scripting language that is used widely on the WWW and is very similar to C in structure. Variables in Perl start with a $. If you want to run the example, download the above and make it executable, (chmod +x roi.pl), change the first line as needed on your system, and run it (i.e ./roi.pl).

Your assignment is to convert the above Perl program to Java. Call the public class ROI and put your code into an ROI.java file.

The usage will be like this on the command line: java ROI INITIAL ADDITION RETURN PERIODS
For example: java ROI 4000 2000 11 40

You should use the Integer.parseInt() method to parse command line arguments to integers. The DecimalFormat class can be used to output the results in a monetary form. See The Java Tutorial, the text or other reference for more info on these classes. (Note: The numbers are given as command line arguments, not read in from standard input.)

Your code should also be well documented in javadoc format. You should also run javadoc on your source and include the output on your homepage in a cis370/proj1 subdirectory. If you do not use the composer webserver make sure your TA knows the proper URL. Be sure to only make your documentation public, not any of your actual code.

You can assume that the input given will be numbers.

Sample output

	% java ROI 4000 2000 9 10
	year amount
	0   $4,000.00
	1   $6,360.00
	2   $8,932.40
	3   $11,736.32
	4   $14,792.58
	5   $18,123.92
	6   $21,755.07
	7   $25,713.03
	8   $30,027.20
	9   $34,729.65
	10   $39,855.31

Grading

Calculator coding- 60%
Calculator test runs- 20%
javadoc documentation on your webpage - 20%

Turn In

Download the proj1-run.sh script, make it executable (chmod +x) and run it as shown below (./proj1-run.sh). This will supply all information needed to grade 80% of the assignment including some test runs.

Run the following:

script proj1.scr
cd to your proj1 directory
./proj1-run.sh
exit
Print out the proj1.scr file and turn it in (pages stapled with no blue print header sheets and name clearly visable). Also run javadoc on your source and add it to your webpage. The TA will grade it from there. (Note: None of your java source code should go on the web page, just you documentation... putting source code up on the web will result in points being deducted.)