Lab04CodeFragments - private double yearsToWithdraw private...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 //================== Click event in frmMain ================ private void btnCalcActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: double irate double start double end double years double amount double balance String buff try { irate = Double.parseDouble(txtInterestRate.getText()) start = Double.parseDouble(txtStartAmount.getText()) years = Double.parseDouble(txtYearsToWithdraw.getText()) amount = Double.parseDouble(txtAmountToWithdraw.getText()) ClsAnnuity myAnnuity = new ClsAnnuity(irate, years, start, amount) balance = myAnnuity.getEndingBalance() buff = String.format("$%.2f", balance) txtEndingBalance.setText(buff) txtYearsFundLasts.setText(Double.toString(myAnnuity.getYears())) } catch (Exception ex) { System.out.println(ex.getMessage()) } } //================= ClsAnnuity =================================================== public class ClsAnnuity { //============================== Instance Members =================== private double interestRate
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: private double yearsToWithdraw private double startingBalance private double endingBalance private double annualWithdrawal //============================== Constructor ======================== public ClsAnnuity(double i, double ytw, double sb, double aw) { if (i > 1.0) i *= .01 interestRate = i Sheet1 Page 2 if (ytw > 0.0) yearsToWithdraw = ytw if (sb > 0.0) startingBalance = sb if(aw > 0.0) annualWithdrawal = aw } //============================== Property methods ==================== public double getYears() { return yearsToWithdraw } //============================== General Methods ===================== public double getEndingBalance() { int i double interest double bal = startingBalance double end for (i = 0 { interest = interestRate * bal bal = interest + bal bal -= annualWithdrawal if (bal < 0) break } yearsToWithdraw = i return bal } } Sheet1 Page 3 Sheet1 Page 4 i < (int) yearsToWithdraw i++)...
View Full Document

This note was uploaded on 04/18/2008 for the course CIT 295 taught by Professor Purdum during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 4

Lab04CodeFragments - private double yearsToWithdraw private...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online