So, i have to methods in a non main class and i need to figure out how to print both the println in a chart with two columns
should look something like this

x : y
x : y
x : y
x : y
x : y

but instead i print like this
x
x
x
x
x
y
y
y
y
y

this is my code , any help would be appreciated

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author vazquez
 */
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;
            NumberFormat nf = NumberFormat.getCurrencyInstance();
            System.out.println(nf.format(answer));
        }

    }
    @Override
    public String toString()//@override
    {
        String answer = "";
        Calendar greg = Calendar.getInstance();
        greg.set( 2010, Calendar.DECEMBER, 31);
        DateFormat formatter = DateFormat.getDateInstance();
        for(int index = 0 ; index < years.length ; index ++)
        {
            greg.add(Calendar.YEAR, 1);
            Date gregsTime = greg.getTime();
            System.out.println(formatter.format(greg.getTime()));
        }
        return(answer);
    }
}

Recommended Answers

All 2 Replies

With that as your starting point? Not at all. And see your other thread.

yes , i know and i appreciate you for taking time and looking at my pityful coding, but this is a single class of my 3 class project one containing the main method and the other two been constructors this one holdiing the array and the other class should use for each index in the array :)

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.