Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following code. class BankAccount { var accountBalance: Float var accountNumber: Int init(number: Int, balance: Float) { accountNumber = number accountBalance = balance }

Consider the following code.

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: 17932020, balance: 1001.00, rate: 0.109)

print(savings1.calculateInterest())

savings1.displayBalance()

a) What is the output of the above code?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions