func displayBalance
class BankAccount {
var accountBalance: Float
var accountNumber: Int
init(number: Int, balance: Float) {
accountNumber = number
accountBalance = balance
}
func displayBalance() {
print("Number \(accountNumber)")
print("Current balance is \(accountBalance)")
}
}
class SavingsAccount: BankAccount {
var interestRate: Float = 0.0
init(number: Int, balance: Float, rate: Float) {
super.init(number: number, balance: balance)
interestRate = rate
}
func calculateInterest() -> Float {
return interestRate * accountBalance
}
override func displayBalance() {
super.displayBalance()
print("Prevailing interest rate is \(interestRate)")
}
}
let savings1 = SavingsAccount(number: 13062020, balance: 1001.00, rate: 0.109)
print(savings1.calculateInterest())
savings1.displayBalance()