Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Java Homework Help

I have a Java assignment due tomorrow that I am currently struggling with. It deals with calculating Annuity and Present Values. At this point I am completely lost and don't know how to continue. This assignment is in preparation for our midterm next week, so it is extremely important that I figure out how to do it. This is my first post and any help is appreciated!

Assignment:

Part 1: Basic Java Application Create a basic Java application that can be used to calculate Present Value for various annuities. Your application should be created based on the design shown in the class diagram of Figure 1.

Annuity.java – This class models an annuity. An annuity object will store the following data:

• payment – the constant amount paid at the end (or beginning) of each period.
• term – the total number of periods for the annuity.
• rate – the discount rate for the term
• type – an integer code signifying the type of the annuity. Use 0 for an ordinary annuity and use 1 for an annuity due.

Methods include the basic constructors, setters, getters and toString shown in the class diagram. Additional methods are:
• getPVOFactor: returns a double representing the present value factor for the current state of the annuity object.
• getPVOFactor(rate, term): returns a double representing the present value factor for the values passed into the method.

A PVO Factor can be calculated using: PVO factor = (1 - (1 / (1 + rate) term)) / rate;
PresentValue.java – This is a helper class with methods that can be used to calculate the present value of a single annuity or print a table of PVO factors. The only field should be an annuity object. In addition to the constructors, getters and setters, this class should have the methods:
• getPV(): returns a double value representing the present value for the annuity in dollars.
• getPVOAFactorTable(): a static method that can be used to print a PVOA factor table that one can use as a reference when calculating annuity present values manually.

Controller.java – a class that includes a main() method. This class is used to create Annuity and PresentValue objects as needed. You should test your application by creating a few annuity objects, hand them to a presentValue object, print the state of an annuity to the console, print the present value of the annuity to a console, and finally, print a PVOA Factor table like that shown in the sample output.

JUNIT test for Annuity: Create a JUNIT test class that tests the Annuity class (all methods). Your final version to submit should include valid tests (no errors) that are all successful.

Part 2: Dynamic Java Web Application
Create a Java Web Application with an appropriate source package for Java classes that deal with financial calculations. Copy your Annuity.java and PresentValue.java classes into this package.

This application should perform pretty much the same function as your part 1 application, but do this as a Web application. Instead of a controller class, you should include two JSPs: one called index and an appropriate name for the second. The index.jsp component should deliver a form like that shown in Figure 4 below.
When the calculate button is clicked, the second JSP component should return output to the browser that looks like that shown in Figure 5.

For part 2 you must include the following:
• an index.jsp component to deliver the form to the browser
• a second jsp file to handle the output view
• include copies of the PresentValue.java and Annuity.java classes from part 1 – unchanged unless otherwise specified here.
• Use CSS to style both pages. Include style commands that affect: font face, style and color; layout; background and your table.
• Add a new method to the PresentValue.java class that will return a String for printing the table with html tags to the browser.

What I've done so far:
Controller Class: Controller Class - Pastebin.com
Annuity Class: import static org.junit.Assert.*; import org.junit.Test; public class An - Pastebin.com
PresentValue Class import static org.junit.Assert.*; import org.junit.Test; public class Pr - Pastebin.com