so i am working on a assigment for school, and i need help with the java.util.Calendar , i am trying to increment the year of as today by one each index of an array . This functions needs to be inside a toString(). so i need some help i know i need a for loop to pass the add(calendar.YEAR, index)
here is what i have so far ..ohh yeah this class should not have a main method.
import java.util.Date;
import java.util.Calendar;
import java.text.DateFormat;
import java.text.NumberFormat;
public class RetiermentCalculator
{
AccountInformation[] years = new AccountInformation[35];
public RetiermentCalculator(int aYear, double aBeginIncome, double aContribution, double aReturn )
{
double answer = 0.0;
double finance = (aBeginIncome + aContribution);
double intrestMade = finance * aReturn;
for (int index = 0; index < years.length; index ++)
{
answer += finance + intrestMade;
System.out.println(answer);
}
}
@Override
public String toString()//@override
{
String answer = "";
Calendar greg = Calendar.getInstance();
Date sometime = greg.getTime();
DateFormat formatter = DateFormat.getDateInstance();
for(int index = 0 ; index < years.length; index ++)
{
greg.add(greg.YEAR, index);
answer = formatter.format(sometime);
}
return(answer);
}
}