I am having a nightmare time with an assessment task. I am only a newie at Java and I am not sure what I am doing.

In the program I need to create a investment calculator that will enable the user to input a payement amount, how many payments and the interest rate. They then with have the choice of a single payement or annual payments. The results fo the payments are then passed onto a barchart and also printed in a terminal window.

I have created the method for caluclating the single payment option but can not for the life of me work out the annual payments. i know that i need to use an array and a loop but I am not sure how to construct it. Can you help me at all????

here is my coding so far for for the single payment and the structure for the annual payments:

import com.grapher.Valuable;
public class Payment implements Valuable
{
private double paymentAmount;
private int paymentTime;
 
public Payment(double aPaymentAmount, int aPaymentTime)
{
paymentAmount = aPaymentAmount;
paymentTime = aPaymentTime;
}
public double getValue (int valuationTime, double valuationRate)
{
return paymentAmount*Math.pow((1+(valuationRate/100)),valuationTime);
}
 
 
 
}
publicClass PaymentSeries implemets Valuable
{
ArrayList Payments;
 
public PaymentSeries()
{
 
double paymentAmount;
int paymentTime;
}
 
public void addPayment(Payment P)
{
 
}
Member Avatar for iamthwee

>i know that i need to use an array and a loop but I am not sure how to construct it. Can you help me at all????

Well have you tried searching for a java tutorial regarding arrays and loop structures using google?

Do you have a flow chart?

Do you know how to calculate interest rates on paper?

Thanks for you help, I have tried to look for a useful tutorial on arrays and loops but i haven't relly found any good ones....can you suggest one?

I have a class that calcutates the interest using a get method. Here is the code for that class:

import com.grapher.Valuable;
public class Payment implements Valuable
{
private double paymentAmount;
private int paymentTime;
 
public Payment(double aPaymentAmount, int aPaymentTime)
{
paymentAmount = aPaymentAmount;
paymentTime = aPaymentTime;
}
public double getValue (int valuationTime, double valuationRate)
{
return paymentAmount*Math.pow((1+(valuationRate/100)),valuationTime);
}
 
 
 
}

The com.graapher is a programme that my lecturer created for us to use. I could send a zip file with everything and then you might get a clearer picture of what i am trying to do. do you know if i can upload a file?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.