Bradley Jordan
greenhorn
Member # 143948
posted Yesterday 8:09 PM
--------------------------------------------------------------------------------
I am currently taking a
Java class. I have a project that wants me to repeat the output within a JOptionPane.
here is my code so far
public double valueOfMoney(double amountOfMoney, int lengthOfTime)
{
double x = amountOfMoney;
int y = lengthOfTime;
int loopcount = 0;
String allString;
while (loopcount < y)
{
x = x * (1 + constant);
x = (int)(x * 100) / 100.0;
loopcount += 1;
allString = "The amount at end of year " + loopcount + " is $" + x;
JOptionPane.showConfirmDialog(null, allString + "\n" + x, "Investment Resutls",JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE);
}
return x;
}
This prints out the results in the pane but it goes to another pane what I want is something like this all withing the same pane.
The amount of year 1 is $x.xx
The amount of year 2 is $x.xx
etc.....
This is possible? Can it be done from the same method? I have taken the JOPtionPane out of the loop but it only gives me the last iteration through. What I need is a way to store the data for each iteration and than a way to print it all out at once.
Please help. I greatly appreicate any help.
Thanks,
Bradley Jordan