There are 3 files:
1. Annuuity.java
2. AnnuityDueGUI.java // GUI for Annuity Due
2. AnnuityDueResultGUI.java //GUI for the result
Under AnnuityDueGUI.java:
public double calculateFADGUI(){
//FVA = A{[(1+i)^n – 1] / i} (1+i)
String amountStr = amount.getText() ; //convert string to double
dAmount = Double.parseDouble(amountStr) ;
String iStr = iText.getText() ;
dInterest = Double.parseDouble(iStr) ;
String periodStr = period.getText() ;
dPeriod = Double.parseDouble(periodStr) ;
iPeriod = (int)dPeriod ;
due = new Annuity(dAmount, dInterest, iPeriod) ;
System.out.println(due.calculateFAD()) ;
return due.calculateFAD() ; //calculateFAD() is under Annuity.java
}
Under AnnuityDueResultGUI.java:
AnnuityDueGUI due ;
public AnnuityDueResultGUI(AnnuityDueGUI due){ //1st solution failed
this.due = due ;
}
public void grabResult(){ //1st solution failed
result = this.due.calculateFADGUI() ;
}
public AnnuityDueResultGUI(){
JPanel p6 = new JPanel() ;
p6.setLayout(new GridLayout(2, 1)) ;
p6.add(new JLabel("you will have approximately $" + result)) ;
// other codes
}
From AnnuityDueGUI.java I am able to see the result of due.calculateFAD() . But, I would like to display the result under AnnuityDueResultGUI.java
I already did put them under a package named 'GUI' and also did import AnnuityDueGUI.java and Annuity.java.
I did the steps that was recommended in this forum on my other same question using unregisterd user. But, it did not work(the passed result is 0). That's why I'm posting the same question again with more details.
Please assist and thank you in advance.