Help Please
I'm trying to make a program to compound interest using two classes. One with the compounding method and one as the main. I'm having trouble outputting the result from the compounding method through the main. The name of the variable I'm trying to output is "result." I'm required to use two classes and the output must derive from the main. Here's my code; I would appreciate any assistance.
PS. I know that the formula for interest is wrong, I'm just trying to get it working right now. Everything else seems to work fine when I take out the double result from the output line.
Thanks
Compound Class
import javax.swing.*;
publicclass SquiresCI{
publicdouble getFinal(double num1,double num2,double num3)
{
double result = num1 + num2;
return result;
}
}
MAIN CLASS
import javax.swing.*;
publicclass SquiresProject2
{
publicstaticvoid main(String[] args)//start of main method
{
String principalString, interestString, durationString;
double num1, num2, num3;
boolean repeat;
SquiresCI compound =new SquiresCI();
do{
int select;
principalString =
JOptionPane.showInputDialog("Please enter the amount of money you'd like to invest in dollars:");
num1 = Double.parseDouble(principalString);
durationString =
JOptionPane.showInputDialog("How many years will you be investing for?");
num2 = Double.parseDouble(durationString);
interestString =
JOptionPane.showInputDialog("What will the rate of interest be(%)?");
num3 = Double.parseDouble(interestString);
compound.getFinal(num1, num2, num3);
JOptionPane.showMessageDialog(null,"Your final amount will be: " + result);//THIS IS THE PROBLEMATIC LINE
//displays run again dialog -- presents two buttons, one for yes the other for no
select = JOptionPane.showConfirmDialog(null,"Run Again?","Run Again Dialog",JOptionPane.YES_NO_OPTION);
//if yes is selected "runagain" equates to true if no is selected "runagain" equates to false
repeat = (select == JOptionPane.YES_OPTION);
}while (repeat);

