Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Challenge 2: Handling a Bank Account

Sumit Rawal answered on May 17, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Challenge 2: Handling a Bank Account

0

Problem statement

In this challenge, we will implement methods in the parent class and its corresponding child class.

The initializers for both classes have been defined for you.

Task 1

In the Account class, implement the getBalance() method that returns balance.

Task 2

In the Account class, implement the deposit(amount) method that adds amount to the balance. It does not return anything.

Sample input

balance = 2000

deposit(500)

getbalance()

Sample output

2500

Task 3

In the Account class, implement the withdrawal(amount) method that subtracts the amount from the balance. It does not return anything.

Sample input

balance = 2000

withdrawal(500)

getbalance()

Sample output

1500

Task 4

In the SavingsAccount class, implement an interestAmount() method that returns the interest amount of the current balance. Below is the formula for calculating the interest amount:

Sample input

balance = 2000

interestRate = 5

interestAmount()

Sample output

100

The following figure shows what the result should logically look like:

Based and Derived Classes Structure

Coding exercise

Design a step-by-step algorithm before jumping to the implementation. This problem is designed for your practice, so initially try to solve it on your own. If you get stuck, you can always refer to the solution provided in the next lesson.

Good luck! 

Popularity 1/10 Helpfulness 1/10 Language python
Source: Grepper
Link to this answer
Share Copy Link
Contributed on May 17 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.