Bank Accounts (Use Python) Write a program that accepts bank transactions and prints out the balance of an account afterwards. PROGRAM DESIGN Create a class named bankAccount. A bank account should have the following attributes: accNumber, balance, and dateOpened. This class should also have the option to do the following transactions: deposit, withdraw and drop. Initially there is only one bankAccount active in the program, with a balance amount of 1515, and was opened back in 10/01/1987. Depositing adds to a current bankAccount’s balance, while withdrawing – does otherwise. Dropping would equate the current balance to zero. Refer to the following class diagram for more details about the current bankAccount: bankAccount accNumber = 1 balance = 1515 dateOpened = "10/27/1987" deposit(dep) withdraw(wd) drop(accNumber) INPUT The input would be a string that contains the following data: the transaction to be done (dep – for deposit, wd – for withdraw and drop – for drop), the accNumber, and how much to be withdraw or deposited (0 if drop is involved). These data are separated by spaces. OUTPUT Once the user enters the input, the program should be print an output based on the transaction and the amount provided by the user. However, if the user misspells or enters a non-existent transaction, or inputs a non-existent account number, the text “Invalid Transaction!” should be displayed. SAMPLE INPUT dep 1 1000 wd 1 1516 drop 1 0 depo 1 21000 drop 2 2000 SAMPLE OUTPUT 2515 -1 0 Invalid Transaction! Invalid Transaction!
Bank Accounts (Use Python)
Write a
PROGRAM DESIGN
Create a class named bankAccount. A bank account should have the following attributes: accNumber, balance, and dateOpened. This class should also have the option to do the following transactions: deposit, withdraw and drop. Initially there is only one bankAccount active in the program, with a balance amount of 1515, and was opened back in 10/01/1987.
Depositing adds to a current bankAccount’s balance, while withdrawing – does otherwise. Dropping would equate the current balance to zero. Refer to the following class diagram for more details about the current bankAccount:
bankAccount
accNumber = 1
balance = 1515
dateOpened = "10/27/1987"
deposit(dep)
withdraw(wd)
drop(accNumber)
INPUT
The input would be a string that contains the following data: the transaction to be done (dep – for deposit, wd – for withdraw and drop – for drop), the accNumber, and how much to be withdraw or deposited (0 if drop is involved). These data are separated by spaces.
OUTPUT
Once the user enters the input, the program should be print an output based on the transaction and the amount provided by the user. However, if the user misspells or enters a non-existent transaction, or inputs a non-existent account number, the text “Invalid Transaction!” should be displayed.
SAMPLE INPUT
dep 1 1000
wd 1 1516
drop 1 0
depo 1 21000
drop 2 2000
SAMPLE OUTPUT
2515
-1
0
Invalid Transaction!
Invalid Transaction!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images