Question

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

Homework Answers

Answer #1


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

'''

Know the answer?
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
Similar Questions
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
The first script you need to write is login.sh, a simple script that you might run...
The first script you need to write is login.sh, a simple script that you might run when you first log in to a machine. We'll expand this script later, but for now it should include your name, username, hostname, current directory, and the current time. Here is some sample output to help guide you. Note that the bolded lines that start with "[user@localhost ~]$" are the terminal prompts where you type in a command, not part of the script. Of...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all...
Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all user information from a given input file. The input file contains information of a user in following order: username, first name, last name, password, account number and account balance. Information is separated with ‘|’. o username is a unique information, so no two users will have same username. Sample input file: Username eaglebank has password 123456, account number of BB12 and balance of $1000....
MIPS ASSEMBLY Have the user input a string and then be able to make changes to...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to the characters that are in the string until they are ready to stop. We will need to read in several pieces of data from the user, including a string and multiple characters. You can set a maximum size for the user string, however, the specific size of the string can change and you can’t ask them how long the string is (see the sample...
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such as a cube, sphere, cylinder and cone. In this file there should be four methods defined. Write a method named cubeVolFirstName, which accepts the side of a cube in inches as an argument into the function. The method should calculate the volume of a cube in cubic inches and return the volume. The formula for calculating the volume of a cube is given below....
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT