Question

In: Computer Science

in paython You are going to make an advanced ATM program When you run the program,...

in paython

You are going to make an advanced ATM program

When you run the program, it will ask you if you want to:

  1. Either log in or make a new user

  2. Exit

Once I have logged in, I will have 3 balances, credit, checking, and savings. From here it will ask which account to use.

Once the account is picked they can deposit, withdraw, check balance, or log out.

Each time the user performs one of these actions, it will loop back and ask them for another action, until the Logout

(Hint: Make sure they can’t withdraw too much money)

Submission name: Advanced_ATM.py

(Capitalization matters for this, any non .py files will be -20 points)

Submit the file here by the assigned date, every day late will be 15 points off

Solutions

Expert Solution


class Account:
   def __init__(self,username,password):
       self.username = username
       self.password = password
       self.credit_bal = 0
       self.checking_bal = 0
       self.savings_bal = 0
  
   def deposit(self,amount,ac_type):
       if(ac_type == "credit"):
           self.credit_bal += amount
           print("\nTransaction Success. Successfully deposited in Credit Account")
       elif(ac_type == "checking"):
           self.checking_bal += amount
           print("\nTransaction Success. Successfully deposited in Checking Account")
       elif(ac_type=="savings"):
           self.savings_bal += amount
           print("\nTransaction Success. Successfully deposited in Savings Account")
  
   def withdraw(self,amount,ac_type):
       if(ac_type == "credit"):
           if(self.credit_bal < amount):
               print("\nError: Insufficient funds in Credit Account")
           else:
               self.credit_bal -= amount
               print("\nTransaction Success. Successfully withdrawed from Credit Account")
       elif(ac_type == "checking"):
           if(self.checking_bal < amount):
               print("\nError: Insufficient funds in Checking Account")
           else:
               self.checking_bal -= amount
               print("\nTransaction Success. Successfully withdrawed from Checking Account")
       elif(ac_type=="savings"):
           if(self.savings_bal < amount):
               print("\nError: Insufficient funds in Savings Account")
           else:
               self.savings_bal -= amount
               print("\nTransaction Success. Successfully withdrawed from Savings Account")
  
   def check_balance(self,ac_type):
       print("\n")
       if(ac_type == "credit"):
           print("Balance in Credit account:%.2f" %self.credit_bal)
       elif(ac_type == "checking"):
           print("Balance in Checking account:%.2f" %self.checking_bal)
       elif(ac_type=="savings"):
           print("Balance in Savings account:%.2f" %self.savings_bal)
  
   def simulate(self):
       ac_choice = get_choice(acc_menu,0,3)
       ac_type = ""
       if(ac_choice == 0):
           print("\nSuccessfully Logged out")
           return
       elif(ac_choice == 1):
           ac_type = "credit"
       elif(ac_choice == 2):
           ac_type = "checking"
       elif(ac_choice == 3):
           ac_type = "savings"
      
       op_choice = 1
       while(op_choice):
           print("\nCurrent Account Logged in:",ac_type.title())
           op_choice = get_choice(opps_menu,0,3)
           if(op_choice == 0):
               print("\nSuccessfully Logged out")
               break
           elif(op_choice == 1):
               amount = get_amount("\nEnter amount to deposit: ")
               self.deposit(amount,ac_type)
           elif(op_choice == 2):
               amount = get_amount("\nEnter amount to withdraw: ")
               self.withdraw(amount,ac_type)
           elif(op_choice == 3):
               self.check_balance(ac_type)
          
def get_amount(prompt):
   is_valid = False
   amount = 0
   while(not is_valid):
       try:
           amount = float(input(prompt).strip())
           if(amount <1):
               is_valid = False
               print("\nInvalid Amount entered")
           else:
              
               is_valid = True
       except Exception as e:
           print("Invalid Amount entered")
   return amount

def main_menu():
   print("\n--------- Main Menu -------------\n")
   print("1. Login")
   print("2. Register New User")
   print("0. Exit")
   print("Enter your choice: ",end="")

def acc_menu():
   print("\n--------- Select Account Type -------------\n")
   print("1. Credit")
   print("2. Checking")
   print("3. Savings")
   print("0. Log out")
   print("Enter your choice: ",end="")

def opps_menu():
   print("\n--------- Operations -------------\n")
   print("1. Deposit")
   print("2. Withdraw")
   print("3. Check Balance")
   print("0. Log out")
   print("Enter your choice: ",end="")
  
def get_choice(fun,low,high):
   is_valid = False
   choice = 0
   while(not is_valid):
       try:
           fun()
           choice = int(input().strip())
           if(choice < low or choice > high):
               is_valid = False
               print("\nInvalid Choice entered")
           else:
               is_valid = True
       except Exception as e:
           print("\nInvalid Choice entered",fun)
   return choice
def get_username_and_password():
   print("")
   username = input("Enter username: ").strip().lower()
   if(username == ""):
       print("\nError: Empty value for username is not allowed")
       return "",""
  
   password = input("Enter password: ").strip()
   if(password == ""):
       print("\nError: Empty value for password is not allowed")
       return "",""
   return username,password
def main():
   users = {}
   main_choice = 1
   while(main_choice):
       main_choice = get_choice(main_menu,0,2)
       if(main_choice == 1):
           username,password = get_username_and_password()
           if(username != "" and password!=""):
               if(username in users):
                   users[username].simulate()
                  
               else:
                   print("\nUser:",username,"not found in Users array")
      
       elif(main_choice == 2):
           username,password = get_username_and_password()
           if(username in users):
               print("Duplicate User. Unable to add user:",username)
           else:
               users[username] = Account (username,password)
               print("\nSuccessfully created User:",username)
       elif(main_choice == 0):
           print("\nQutting.....")
if __name__ == "__main__":
   main()

'''


--------- Main Menu -------------

1. Login
2. Register New User
0. Exit
Enter your choice: 2

Enter username: john
Enter password: wick

Successfully created User: john

--------- Main Menu -------------

1. Login
2. Register New User
0. Exit
Enter your choice: 1

Enter username: john
Enter password: wick

--------- Select Account Type -------------

1. Credit
2. Checking
3. Savings
0. Log out
Enter your choice: 1

Current Account Logged in: Credit

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 3


Balance in Credit account:0.00

Current Account Logged in: Credit

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 1

Enter amount to deposit: -100

Invalid Amount entered

Enter amount to deposit: 100

Transaction Success. Successfully deposited in Credit Account

Current Account Logged in: Credit

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 3


Balance in Credit account:100.00

Current Account Logged in: Credit

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 2

Enter amount to withdraw: 200

Error: Insufficient funds in Credit Account

Current Account Logged in: Credit

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 2

Enter amount to withdraw: 50

Transaction Success. Successfully withdrawed from Credit Account

Current Account Logged in: Credit

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 3


Balance in Credit account:50.00

Current Account Logged in: Credit

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 0

Successfully Logged out

--------- Main Menu -------------

1. Login
2. Register New User
0. Exit
Enter your choice: 1

Enter username: john
Enter password: wick

--------- Select Account Type -------------

1. Credit
2. Checking
3. Savings
0. Log out
Enter your choice: 2

Current Account Logged in: Checking

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 3


Balance in Checking account:0.00

Current Account Logged in: Checking

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 1

Enter amount to deposit: 100

Transaction Success. Successfully deposited in Checking Account

Current Account Logged in: Checking

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 2

Enter amount to withdraw: 40

Transaction Success. Successfully withdrawed from Checking Account

Current Account Logged in: Checking

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 3


Balance in Checking account:60.00

Current Account Logged in: Checking

--------- Operations -------------

1. Deposit
2. Withdraw
3. Check Balance
0. Log out
Enter your choice: 0

Successfully Logged out

--------- Main Menu -------------

1. Login
2. Register New User
0. Exit
Enter your choice: 0

Qutting.....


------------------
(program exited with code: 0)

Press any key to continue . . .

'''


Related Solutions

Due Sept 25th at 11:55 pm You are going to make an advanced ATM program When...
Due Sept 25th at 11:55 pm You are going to make an advanced ATM program When you run the program, it will ask you if you want to: Either log in or make a new user Exit Once I have logged in, I will have 3 balances, credit, checking, and savings. From here it will ask which account to use. Once the account is picked they can deposit, withdraw, check balance, or log out. Each time the user performs one...
When does a monopolist make a short-run economic profit? When does it make short-run economic loss,...
When does a monopolist make a short-run economic profit? When does it make short-run economic loss, but continue production? When does it shut down?
Consider your own advanced care planning. What advanced directives might you consider? If you couldn’t make...
Consider your own advanced care planning. What advanced directives might you consider? If you couldn’t make your own decisions, who would you ask to do that for you? Do you have a living will? Where is it located? Does anyone know about it? What is included or what would you include in your living will? Who would be your power-of-attorney? What special cultural or religious beliefs do you want to be considered? Do you want anything special to happen after...
Task #1 void Methods Copy the file geometry.cpp. This program will compile, but when you run...
Task #1 void Methods Copy the file geometry.cpp. This program will compile, but when you run it , it doesn’t appear to do anything except wait. That is because it is waiting for user input, but the user doesn’t have the menu to choose from yet. We will need to create this. Above the main, write the prototype for a function called PrintMenu that has no parameter list and does not return a value.    Below the main, write the function...
Have to write a program in Java for an ATM however when compiling after enter w...
Have to write a program in Java for an ATM however when compiling after enter w nothing happens. import java.util.Scanner; public class ATMMain {    public static void main(String[] args) {    double Ibalance = 5000, usermoney, withdrawB, depositD;    String userFname = "X";    String userLname = "X";    String w, d, e, c;    System.out.println("Welcome");    Scanner input = new Scanner(System.in);        System.out.println("Welcome" + " " + userFname + " " + userLname);        System.out.println("your current...
For this project, you are going to write a program to find the anagrams in a...
For this project, you are going to write a program to find the anagrams in a given dictionary for a given word. If two words have the same letters but in different order, they are called anagrams. For example, “listen” and “silent” are a pair of anagrams. **JAVA** First let’s focus on “LetterInventory.java”. Its purpose is to compute the canonical “sorted letter form” for a given word. 1. Implement the constructor, which takes the String input word. You can assume...
this Assignment you are going to find and run 30 unique Cmdlets. It is recommended that...
this Assignment you are going to find and run 30 unique Cmdlets. It is recommended that you watch the lecture on the Help System to see how to call a list of Native Cmdlets in your Windows Powershell runtime environment. In your Windows VM: Run your 30 different Cmdlets one after another (How do i know which commands to run?)
If you were going to run a business with a family member, how would you go...
If you were going to run a business with a family member, how would you go about deciding on the organizational culture you want to create?
Explain this python program as if you were going to present it to a class in...
Explain this python program as if you were going to present it to a class in a power point presentation. How would you explain it? I am having a hard time with this. I have my outputs and code displayed throughout 9 slides. #Guess My Number Program # Python Code is modified to discard duplicate guesses by the computer import random #function for getting the user input on what they want to do. def menu(): #print the options print("\n\n1. You...
in C++ For this program, you are going to implement a stack using an array and...
in C++ For this program, you are going to implement a stack using an array and dynamic memory allocation. A stack is a special type of data structure that takes in values (in our case integers) one at a time and processes them in a special order. Specifically, a stack is what's called a first-in-last-out (FILO) data structure. That is to say, the first integer inserted into the stack is the last value to be processed. The last value in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT