Exercise 8'16 PsuedoCode - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Exercise 8'16 PsuedoCode

Description:

invoke Saver1 and Saver2 on class SavingsAccount. print Balance1 and Balance2 ... SavingsAccount saver2 = new SavingsAccount(3000.00) ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 6
Provided by: micah2
Category:

less

Transcript and Presenter's Notes

Title: Exercise 8'16 PsuedoCode


1
Exercise 8.16PsuedoCode
  • Test.java
  • Declare 2 objects Saver1 and Saver2
  • invoke Saver1 and Saver2 on class
    SavingsAccount
  • print Balance1 and Balance2
  • SavingsAccount.java
  • declare static variable annualInterestRate
  • declare private variable savingsBalance
  • invoke constructor for SavingsAccount
  • Method calculateMonthlyInterest
  • call method modifyInterestRate for current
    interest rate
  • calculate new balance and return

2
Flowchart
3
Source Code
  • Test.java
  • import javax.swing.JOptionPane
  • import SavingsAccount
  • public class Test
  • public static void main( String args )
  • SavingsAccount saver1 new
    SavingsAccount(2000.00)
  • SavingsAccount saver2 new
    SavingsAccount(3000.00)
  • JOptionPane.showMessageDialog(null,
    Balance 1 is


  • saver1.calculateMonthlyInterest() \n
    Balance 2 is
  • saver2.calculateMonthlyInterest() )
  • System.exit( 0 )

4
Source Code
  • SavingsAccount.java
  • public class SavingsAccount extends Object
  • private static double annualInterestRate
  • private doubl savingsBalance
  • public SavingsAccount( double balance )
  • savingsBalance balance
  • public double calculateMonthlyInterest()
  • annualInterestRate modifyInterestRate()
  • double MonthlyInterest savingsBalance
    annualInterestRate / 12
  • savingsBalance savingsBalance
    MonthlyInterest
  • return savingsBalance
  • public static double modifyInterestRate()
  • return 0.04

5
Sample Output
Interest 4
Interest 4
Write a Comment
User Comments (0)
About PowerShow.com