Question

In: Computer Science

i'm working on this assignment where we must simulate a bank account. I am having a...

i'm working on this assignment where we must simulate a bank account. I am having a few issues. The first issue is that for menu option 1 i am struggling to make the program so that I can add the name and balance of the account all at once. For example I would type "mike 350" and it would update the dictionary with a new account and balance, right now i have to open the account then deposit a balance separately using two different menu functions. The second issue i am having is that every account name in the dictionary has the same balance, I need to have each person have a separate balance. The third and last issue I am having is with menu option #6, i am not sure how to list the account names and balances with a number of each account to the left, the professor wants the output to look like this for option 6

No Customer Name   Balance

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

1 joe 10

2 jim 20

3 eric 30

I have made it this far.

def main():
  
print("1. Open an account")
print("2. Close an Account")
print("3. Deposit money")
print("4. Withdrawal money")
print("5. Enquire about balance")
print("6. Print a list of customers and balances")
print("7. Quit")


accounts = {}
balance = 0
main()

while True:
menu_choice = int(input("Type in a menu choice: "))

#menu choice 1
if menu_choice == 1:
number = input("Enter name of the new customer and \nthe amount of money to be deposited \n into the new account (Ex. 'Mike 350'):")
if number in accounts:
print('This customer already exists!')
  
else:
accounts[number]=balance
print ("Account name", number, "opened.")

#menu choice 2
elif menu_choice == 2:
number = input("Account name:")
  
if number not in accounts:
print('Enter the customer/account name to be deleted: ')
if number in accounts:
if balance>0:
print('Can not close an account with balance greater than zero')
else:
del accounts[number]
print ("Account number", number, "is closed.")

#menu choice 3
elif menu_choice == 3:
print ("Enter the customer name for deposit: ")
number = input("Account name: ")
if number in accounts:
deposit = float(input("Enter the amount to be deposited: "))
  
balance += deposit
print ("your balance is:", balance-deposit, "before deposit")
print ("Your balance is:", balance, "after deposit")
else:
print ("This customer doesn't exist!")

#menu choice 4   
elif menu_choice == 4:
number = input("Enter the customer name for withdrawl: ")
if number not in accounts:
print('This customer doesnt exist!')
  
if number in accounts:
withdraw = float(input("Enter the amount to be withdrawn: "))
if withdraw <=balance:
balance -=withdraw
print ('your balance is:', balance+withdraw, 'before withdrawal')
print ("Your balance is:", balance, 'after withdrawal')
if withdraw >balance:
print ('your balance is:', balance, 'before withdrawal')
print ('You dont have enough balance to cover the withdrawal')

#menu choice 5
elif menu_choice == 5:
number = input('Enter the customer name for balance enquiry: ')
if number not in accounts:
print('This customer doesnt exist!')

if number in accounts:
print('your balance is:', balance)
  
#menu choice 6
elif menu_choice == 6:
print ("Accounts")
for x in accounts.keys():
print ('No Customer Name Balance')
print ('============================')
print (x , balance\n)

#menu choice 7
elif menu_choice == 7:
print ("Quit.")
break
else:
print ("Please enter a menu choice between 1 and 6.")

main()

Solutions

Expert Solution

Results


Related Solutions

Hi, I am working on this assignment where we have to read and write to a...
Hi, I am working on this assignment where we have to read and write to a file. Change any code that needs to be changed, I need the wfile and rfile functions to be edited to work and the rest of the program. please change the gets() to something that works. if I need to create a .txt file to run the program pls let me know Thanks in advance for the help //agalloc.c // maintains list of agents infile,...
I am having trouble with a C++ code that I'm working on. It is a spell...
I am having trouble with a C++ code that I'm working on. It is a spell checker program. It needs to compare two arrays, a dictionary, and an array with misspelled strings that are compared to the strings in the dictionary. the strings that are in the second array that is not in the Dictionary are assumed to be misspelled. All of the strings in the dictionary are lowercase without any extra characters so the strings that are passed into...
I'm working in Java and am working on a project where I need to find an...
I'm working in Java and am working on a project where I need to find an average. The catch is that for some of the values there is no data because they will be entered at a later date. I have variables assigned so that for each entry if there is an input I'll have it say _____available = 1, otherwise the variable will equal 0. I'll use an example to make this more clear. Let's say I am trying...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize these entries and post the closing entries 2. i need to prepare Dalhanis multi-step income statement and statement of owners equity for August 2010 3. i need to prepare the blance sheet at august 31,2010 4. i need to prepare a post-closing trial balance at august 31,2010 DALHANI makes all credit sales on terms 2/10 n/30 and uses the Perpetual Inventory System Aug 1...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize...
I am working on an accounting assignment and am having problems. Firstly, 1.I need to journalize these entries and post the closing entries 2. i need to prepare Dalhanis multi-step income statement and statement of owners equity for August 2010 3. i need to prepare the blance sheet at august 31,2010 4. i need to prepare a post-closing trial balance at august 31,2010 DALHANI makes all credit sales on terms 2/10 n/30 and uses the Perpetual Inventory System Aug 1...
Hello, I am working on an assignment but I am unsure of how to solve it....
Hello, I am working on an assignment but I am unsure of how to solve it. Please help me. The assignment details are below. Consider this scenario: Your friend starts a website, nothingbutflags.com, which is not making money. Your friend asks you to help generate more traffic. You ask your friend how much traffic the website had last month? And your friend replies and says only 500 visits. You also ask how many flags did you sell? Your friend replies...
Hello, I am working on an assignment but I am unsure of how to solve it....
Hello, I am working on an assignment but I am unsure of how to solve it. Please help me. The assignment details are below. Consider this scenario: Your friend starts a website, nothingbutflags.com, which is not making money. Your friend asks you to help generate more traffic. You ask your friend how much traffic the website had last month? And your friend replies and says only 500 visits. You also ask how many flags did you sell? Your friend replies...
I am working java project. I need to write methods for text game. I'm working on...
I am working java project. I need to write methods for text game. I'm working on chest class. Description : You should start your work by implementing the Chest class (a skeleton is provided for you). It needs to store whether it is locked or not, a String describing the contents, and which key it was locked with. The method stubs for this class are provided with comments, be sure to implement them the way they are described. You should...
Using dev c++ I'm having trouble with classes. I think the part that I am not...
Using dev c++ I'm having trouble with classes. I think the part that I am not understanding is sending data between files and also using bool data. I've been working on this program for a long time with many errors but now I've thrown in my hat to ask for outside help. Here is the homework that has given me so many issues: The [REDACTED] Phone Store needs a program to compute phone charges for some phones sold in the...
I'm having trouble figuring out the constraints to this problem. I know that I am maximizing...
I'm having trouble figuring out the constraints to this problem. I know that I am maximizing 55x + 45y, however the variables are throwing me off. I only need help on question #1 as it would be a great help to understanding the rest of what the questions are asking. The problem is as follows: NorCal Outfitters manufactures a variety of specialty gear for outdoor enthusiasts. NorCal has decided to begin production on two new models of crampons: the Denali...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT