Question

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 check balance and when finish exit the program

In your answer please include how to bind the input your id function to the customer id on the welcoming panel

Include how to switch between the panels

Please include only working codes

Here is my example code :

class Account(object):
    def __init__(self):
        self.balance = 0
      
    def deposit(self, amount):
        if (amount < 0):
            return 'Please deposit an amount greater than 0'
        self.balance += amount
        print ('Amount deposited {}'.format(amount))
        return 'SUCCESS'
      
    def withdraw(self, amount):
        if (amount < 0):
            return 'Please withdraw an amount greater than 0'
        if (amount > self.balance):
            return 'Please enter an amount less than your account balance'
        self.balance -= amount
        return 'SUCCESS'
  
    def balance(self):
        return self.balance

class SavingsAccount(Account):
    def __init__(self, interestRate):
        super(SavingsAccount, self).__init__()
        print ('Your savings account has been opeend')
        self.interest_rate = interestRate
        self.interest = 0
  
    def compute_interest(self):
        self.interest = self.balance * self.interest_rate
      
    def get_interest(self):
        return self.interest


class CheckingAccount(Account):
    def __init__(self):
        super(CheckingAccount, self).__init__()

def main():
    interestRate = 3 # test run with 3% interest rate
    SavingsObject = SavingsAccount(interestRate)
  
    initialBalance = SavingsObject.balance()
    print ('Initial account balance is {}'.format(initialBalance))
  
    amountToDeposit = 300
    SavingsObject.deposit(amountToDeposit)
    balanceAfterDeposit = SavingsObject.balance()
    print ('Your account balance is {}'.format(balanceAfterDeposit))
  
if __name__ == "__main__":
    main()
   

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

Below is the code with the required functionalities:

class Account(object):

def __init__(self):

self.balance = 0

def deposit(self, amount):

if(amount < 0):

return 'Please deposit an amount greater than 0'

self.balance += amount

print ('Amount deposited {}'.format(amount))

return 'SUCCESS'

def withdraw(self, amount):

if(amount < 0):

return 'Please withdraw an amount greater than 0'

if(amount > self.balance):

return 'Please enter an amount less than your account balance'

self.balance -= amount

return 'SUCCESS'

def balance1(self):

return self.balance

class SavingsAccount(Account):

def __init__(self, interestRate):

super(SavingsAccount, self).__init__()

print ('Your savings account has been opeend')

self.interest_rate = interestRate

self.interest = 0

def compute_interest(self):

self.interest = self.balance * self.interest_rate

def get_interest(self):

return self.interest

class CheckingAccount(Account):

def __init__(self):

super(CheckingAccount, self).__init__()

def main():

flag = 0

for i in range(0,3):

customer_id = input("Enter the Customer ID: ")

if(isValid(customer_id)):

flag = 1

break

else:

if(i==2):

break

print("That's not a valid ID! You have", 2-i, "more chances!")

if(flag==1):

welcomePanel(customer_id)

else:

print("You entered the Customer ID incorrectly 3 times!!!")

print("Exiting the program!")

def isValid(customer_id):

#Insert here the code of checking whether the customer id is valid or not.

#If it is valid, return True, else return False

return True

def welcomePanel(customer_id):

print("MAIN MENU")

print("1. Open a savings account.")

print("2. Check account.")

print("3. Deposit money.")

print("4. Withdraw money.")

print("5. Check balance.")

print("6. Exit.")   

choice = int(input("\nEnter your choice(1-6): "))

interestRate = 3 # test run with 3% interest rate

SavingsObject = SavingsAccount(interestRate)   

if(choice==1):

initialBalance = SavingsObject.balance1()

print ('Initial account balance is {}'.format(initialBalance))

elif(choice==2):

#Insert code to check account. Your CheckingAccount class is incomplete.

return

elif(choice==3):

amountToDeposit = int(input("Please enter the amount to deposit: "))

SavingsObject.deposit(amountToDeposit)

balanceAfterDeposit = SavingsObject.balance1()

print ('Your account balance is {}'.format(balanceAfterDeposit))

elif(choice==4):

amountToWithdraw = int(input("Please enter the amount to withdraw: "))

SavingsObject.withdraw(amountToWithdraw)

balanceAfterWithdraw = SavingsObject.balance1()

print ('Your account balance is {}'.format(balanceAfterDeposit))

elif(choice==5):

print ('Your account balance is {}'.format(SavingsObject.balance1()))

else:

print("Exiting the program!")

if __name__ == "__main__":

main()

Two new functions have been made: isValid() and welcomePanel().

In the main function, the user is asked to enter the customer ID. If he enters an invalid ID, he is asked to enter the valid ID, and he can only enter ID thrice, as mentioned in the requirements.

If he enters the invalid ID all the three times, the program exits saying "You entered the Customer ID incorrectly 3 times!!!". (This output line, however, can be changed as per your preference.) The output in this case is:

The decision of whether the ID is valid or not is based on the implementation of the function isValid(customer_id). The student can write his/her code for checking whether the ID is valid or not, as there can be an infinite number of ways to check that, and it depends on the design of the system.

Now, if the customer enters a valid CustomerID, the control shifts to another function, the welcomePanel(). Here, the user can choose which transaction do they want to make, like opening a savings account, depositing or withdrawing money, checking balance, etc. Depending on the choice they have entered, the corresponding function is performed, and the control shifts back to the main() panel(or function). This is how switching between the two panels is carried out. The sample output is given below:

I've just provided the main underlying structure behind the problem, but inserting the code for mentioned functionalities is dependent on the user.

(Note: I have changed the name of the function balance() to balance1() since it was clashing with the variable balance.)

Hope this helped. If you have any doubts or questions, please feel free to ask in the comments section. If it helped in any way, please consider giving positive ratings.

Add a comment
Know the answer?
Add Answer to:
I am trying to create a ATM style bank program that accept the customer id ,...
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
  • MAIN OBJECTIVE       Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture...

    MAIN OBJECTIVE       Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture an output. polymorphism. Write an application that creates a vector of Account pointers to two SavingsAccount and two CheckingAccountobjects. For each Account in the vector, allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account, determine its...

  • 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...

  • Introduction Extend the inheritance hierarchy from the previous project by changing the classes to template classes....

    Introduction Extend the inheritance hierarchy from the previous project by changing the classes to template classes. Do not worry about rounding in classes that are instantiated as integer classes, you may just use the default rounding. You will add an additional data member, method, and bank account type that inherits SavingsAc-count ("CD", or certicate of deposit). Deliverables A driver program (driver.cpp) An implementation of Account class (account.h) An implementation of SavingsAccount (savingsaccount.h) An implementation of CheckingAccount (checkingaccount.h) An implementation of...

  • The program needs to be in python : First, create a BankAccount class. Your class should...

    The program needs to be in python : First, create a BankAccount class. Your class should support the following methods: class BankAccount (object): """Bank Account protected by a pin number.""" def (self, pin) : init "n"Initial account balance is 0 and pin is 'pin'."" self.balance - 0 self.pin pin def deposit (self, pin, amount): """Increment account balance by amount and return new balance.""" def withdraw (self, pin, amount): """Decrement account balance by amount and return amount withdrawn.""" def get balance...

  • I am currently facing a problem with my python program which i have pasted below where...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

  • NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the...

    NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the current displayed customer PLEASEEEEEEEEEE package bankexample; import java.util.UUID; public class Customer { private UUID id; private String email; private String password; private String firstName; private String lastName;    public Customer(String firstName, String lastName, String email, String password) { this.id = UUID.randomUUID(); this.firstName = firstName; this.lastName = lastName; this.email = email; this.password = password; } public String getFirstName() { return firstName; } public void setFirstName(String...

  • Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’...

    Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this back can deposit (i.e. credit) money into their accounts and withdraw (i.e. debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction. Create base class Account and derived classes SavingsAccount and CheckingAccount that inherit...

  • Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default...

    Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default values for balance #and annual interest rate are 100 and e, respectively). #INITIALIZER METHOD HEADER GOES HERE #MISSING CODE def getId(self): return self._id def getBalance(self): #MISSING CODE def getAnnualInterestRate(self): return self.___annualInterestRate def setBalance(self, balance): self. balance - balance def setAnnualInterestRate(self,rate): #MISSING CODE def getMonthlyInterestRate(self): return self. annualInterestRate/12 def getMonthlyInterest (self): #MISSING CODE def withdraw(self, amount): #MISSING CODE det getAnnualInterestRate(self): return self. annualInterestRate def setBalance(self,...

  • I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i...

    I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...

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