Question

The program needs to be in python :

First, create a BankAccount class. Your class should support the following methods: class BankAccount (object): Bank Accou

0 0
Add a comment Improve this question Transcribed image text
Answer #1

thanks for the question, here is the complete program in python.

===============================================================================

class BankAccount():
    def __init__(self, pin):
        self.pin = pin
        self.balance = 0

    def deposit(self, pin, amount):
        if pin == self.pin:
            if amount > 0:
                self.balance += amount
            else:
                print('Error: Invalid deposit amount provided. Transaction declined.')
        else:
            print('Error: Invalid Pin. Transaction declined.')

    def withdraw(self, pin, amount):
        if pin == self.pin:
            if amount > 0 and amount <= self.balance:
                self.balance -= amount
            else:
                print('Error: Invalid withdraw amount provided. Transaction declined.')
        else:
            print('Error: Invalid Pin. Transaction declined.')

    def get_balance(self):
        return self.balance

    def change_pin(self, oldpin, newpin):
        if oldpin == self.pin:
            self.pin = newpin
            print('New pin updated updated successfully.')
        else:
            print('Error: Invalid Pin. Transaction declined.')


class SavingsAccount(BankAccount):
    interestRate = 0.06

    def __init__(self, pin):
        super().__init__(pin)

    def addInterest(self):
        self.balance += self.balance * SavingsAccount.interestRate
        print('Interest added to account successfully.')


def main():
    pin = input('Enter initial Pin: ')
    savingAccount = SavingsAccount(pin)
    print('Your savings account has been created successfully.')
    while True:
        print('Menu')
        print('[1]Deposit [2]Withdraw [3]Get Balance [4]Change PIN [5]Add Interest [6]Quit')
        choice = input('Enter choice: ')

        if choice == '1':
            pin = input('Enter pin: ')
            amount = float(input('Enter deposit amount: '))
            savingAccount.deposit(pin, amount)
        elif choice == '2':
            pin = input('Enter pin: ')
            amount = float(input('Enter withdraw amount: '))
            savingAccount.withdraw(pin, amount)
        elif choice == '3':
            print('Savings Account Balance: ${:,.2f}'.format(savingAccount.get_balance()))
        elif choice == '4':
            oldpin = input('Enter old pin: ')
            newpin = input('Enter new pin: ')
            savingAccount.change_pin(oldpin, newpin)
        elif choice == '5':
            savingAccount.addInterest()
        elif choice == '6':
            break
        else
:
            print('Error: Invalid choice.')


main()

===============================================================================

class BankAccount (): def __init__(self, pin): self.pin = pin self. balance = 0 def deposit (self, pin, amount): if pin == se

class SavingsAccount (BankAccount): interestRate = 0.06 definit_(self, pin): super(). init (pin) def addInterest (self): self

Add a comment
Know the answer?
Add Answer to:
The program needs to be in python : First, create a BankAccount class. Your class should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static...

    TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...

  • PYTHON The provided code in the ATM program is incomplete. Complete the run method of the...

    PYTHON The provided code in the ATM program is incomplete. Complete the run method of the ATM class. The program should display a message that the police will be called after a user has had three successive failures. The program should also shut down the bank when this happens. [comment]: <> (The ATM program allows a user an indefinite number of attempts to log in. Fix the program so that it displays a message that the police will be called...

  • I am trying to create a ATM style bank program that accept the customer id ,...

    I am trying to create a ATM style bank program that accept the customer id , in the welcoming panel ,but how do i make when the customer input their id# and click on the ok button then they have 3 or so tries to input the correct id# and if successful then send to the other panel where they choose which transaction to they want to make for example savings , checking account , make and deposit , and...

  • In this, you will create a bank account management system according to the following specifications: BankAccount...

    In this, you will create a bank account management system according to the following specifications: BankAccount Abstract Class contains the following constructors and functions: BankAccount(name, balance): a constructor that creates a new account with a name and starting balance. getBalance(): a function that returns the balance of a specific account. deposit(amount): abstract function to be implemented in both Checking and SavingAccount classes. withdraw(amount): abstract function to be implemented in both Checking and SavingAccount classes. messageTo Client (message): used to print...

  • Java - In NetBeans IDE: •Design an abstract class called BankAccount which stores the balance. –Implement...

    Java - In NetBeans IDE: •Design an abstract class called BankAccount which stores the balance. –Implement a constructor that takes the balance (float). –Provide abstract methods deposit(amount) and withdraw(amount) •Design a class called SavingsAccount which extends BankAccount. –Implement a constructor that takes the balance as input. –It should store a boolean flag active. If the balance at any point falls below $25, it sets the active flag to false. It should NOT allow the balance to fall below $0. –If...

  • In python: Make a BankAccount class. The class should have the initial balance be set to...

    In python: Make a BankAccount class. The class should have the initial balance be set to a parameter passed into the constructor, but should be 0 if no such parameter is passed in. It should have a method called "withdraw" that withdraws an amount that's supplied as a parameter and returns the new balance. It should also have a method called "deposit" that deposits an amount that's supplied as a parameter and returns the new balance. Both "withdraw" and "deposit"...

  • c++ please    Define the class bankAccount to implement the basic properties of a bank account....

    c++ please    Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member func- tions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 compo- nents of...

  • C++ Please create the class named BankAccount with the following properties below: // The BankAccount class...

    C++ Please create the class named BankAccount with the following properties below: // The BankAccount class sets up a clients account (name & ID), keeps track of a user's available balance. // It also keeps track of how many transactions (deposits and/or withdrawals) are made. public class BankAccount { Private String name private String id; private double balance; private int numTransactions; // Please define method definitions for Accessors and Mutator functions below Private member variables string getName(); // No set...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT