Savings Bank Account
Details of the customer’s savings account and saving account need to be maintained by a private bank for easy access. Develop a program to store the information.
Create a base class named Account with instance member’s(accountNumber,holderName,balance) and a constructor to initialize the data member’s
Create a dervied class SavingAccount with instance member(availableBalance), which inherits the Account class, and holds all the properties of the Account and method calculateBalance(withdrawalAmount) which should calculate the balance after the withdrawal of amount and set the value for available balance. Since it is a savings account there must be a minimum balance after the withdrawal. The minimum balance for savings account is Rs.500.
Create a dervied class CurrentAccount with instance member(availableBalance), which inherits the Account class, and holds all the properties of the Account and method calculateBalance(withdrawalAmount) which should calculate the balance after the withdrawal of amount and set the value for available balance. Since it is a current account the Withdrawal amount cannot be more than Rs.30000, if it is more than Rs.30000 then only Rs.30000 should be deducted from the balance.
In the Main class get the input of the account type, customers, and withdraw amount and display the customer details with available balance after transaction based on account type, if account type is SavingAccount create an object for SavingAccount class and using the same calculate the balance and display the details of customer.if account type is CurrentAccount create an object for CurrentAccount class and using the same calculate the balance and display the details of customer.
Note:
Strictly follow the naming conventions for variables and functions as specified in the problem description.
The SavingsAccount class object should be s_account_obj
The CurrentAccount class object should be c_account_obj
All the attribute values should be user inputs and store those values into the variables with the name:
accountNumber for storing Account Number.
holderName for storing Account Holder Name.
balance for storing Balance.
withdrawl for storing withdrawl amount.
Sample Input 1:
1.Savings Account
2.Current Account
Enter the choice
1
Enter the Details:
Account Number
AC76HJ
Holder Name
Mahir
Balance
2600
Withdrawal amount
2500
Sample Output 1:
Account Details
AC76HJMahir2600.0
Sample Input 2:
1.Savings Account
2.Current Account
Enter the choice
2
Enter the Details:
Account Number
BN65RT
Holder Name
Christy
Balance
60000
Withdrawal amount
50000
Sample Output 2:
Account Details
BN65RTChristy30000.0
Code :-
class Account: def __init__(self,accountNumber,holderName,balance): self.accountNumber=accountNumber self.holderName=holderName self.balance=balance def get_accountNumber(self): return self.accountNumber def get_holderName(self): return self.holderName def get_balance(self): return self.balance class SavingAccount(Account): def __init__(self,accountNumber,holderName,balance,availableBalance=0): Account.__init__(self,accountNumber,holderName,balance) self.availableBalance=self.balance def calculateBalance(self,withdrawalAmount): if (self.availableBalance - withdrawalAmount >= 500) : self.availableBalance = self.balance - withdrawalAmount def get_availableBalance(self): return self.availableBalance def display_Account_details(self): print("Account Details\n",self.get_accountNumber(),"\n",self.get_holderName(),"\n",self.get_availableBalance()) class CurrentAccount(Account): def __init__(self,accountNumber,holderName,balance): Account.__init__(self,accountNumber,holderName,balance) self.availableBalance=self.balance def calculateBalance(self,withdrawalAmount): if withdrawalAmount>30000: self.availableBalance=30000 else: self.availableBalance=self.balance-withdrawalAmount return self.availableBalance def display_Account_details(self): print("Account Details\n",self.get_accountNumber(),"\n",self.get_holderName(),"\n",self.get_availableBalance()) choice=int(input("1.Saving Account\n2.Current Account\nEnter the choice\n")) print("Enter the Details:") accountNumber=input("Account Number\n") holderName=input("Holder Name\n") balance=float(input("Balance\n")) withdrawal=float(input("Withdrawal amount\n")) if choice==1: s_account_obj=SavingAccount(accountNumber,holderName,balance) s_account_obj.calculateBalance(withdrawal) s_account_obj.display_Account_details() elif choice==2: c_account_obj=CurrentAccount(accountNumber,holderName,balance) c_account_obj.calculateBalance(withdrawal) c_account_obj.display_Account_details()