Main Menu: 1. Checking 2. Savings 3. Print Balances 4. Exit Checking Menu: 1. De
ID: 3785611 • Letter: M
Question
Main Menu:
1. Checking
2. Savings
3. Print Balances
4. Exit
Checking Menu:
1. Deposit
2. Withdraw
3. Return to Main Menu
Please enter your choice: 1
Enter the amount to deposit: 40
Checking Menu:
1. Deposit
2. Withdraw
3. Return to Main Menu
Please enter your choice: 2
Enter the amount to withdraw: 300
Withdrawal not processed – overdrafts are not allowed
Checking Menu:
1. Deposit
2. Withdraw
3. Return to Main Menu
Please enter your choice: 3
Main Menu:
1. Checking
2. Savings
3. Print Balances
4. Exit
Please enter your choice: 2
Savings Menu:
1. Print total interest earned
2. Calculate Interest
3. Close Savings Account
4. Return to Main Menu
Please enter your choice: 1
Savings Account Balance is $200.00
Savings:
1. Print total interest earned
2. Calculate Interest
3. Close Savings Account
4. Return to Main Menu
Please enter your choice: 2
Interest earned this period: $2.00
Savings:
1. Print total interest earned
2. Calculate Interest
3. Close Savings Account
4. Return to Main Menu
Please enter your choice: 2
Interest earned this period: $2.02
Savings:
1. Print total interest earned
2. Calculate Interest
3. Close Savings Account
4. Return to Main Menu
Please enter your choice: 3
Savings account has been closed. Total Interest earned: $4.02 Ending Balance: $204.02
Savings:
1. Print total interest earned
2. Calculate interest
3. Close Savings Accoung
4. Return to Main Menu
Please enter your choice: 4
Main Menu:
1. Checking
2. Savings
3. Print Balances
4. Exit
Please enter your choice: 4
--End of Program—
CSIS 153 Program 4 20 pts Spring 2017 Write a Python program that creates menus and submenus as shown in the sample run below NOTE: You are REQUIRED to use the CreateMenu function that was previously written to create all of the menus for this program, but alter it so that it accepts TWO arguments: def CreateMenu(optionList, menuTitle) Description returns a string that, when printed, will list the options vertically with numbers preceding each option Precondition: optionList must be a list of strings, menuTitle must be a string Menus to be created for this program: o Main Menu options for Checking, Saving, Print Balances, Exit o Checking Menu: options for Deposit, Withdraw, or Return to the Main Menu o Savings Menu options for Print Total Interest Earned, Calculate Interest, Close Savings Account. Return to the Main Menu Create a function called getValidChoice: def ustring, menuTitle, n getValidChoice(menu Description: prints the menuTitle and the menu String and continues to print the menuTitle and menuString and askthe user to enter a choice until they enter a valid numeric choice that is in the proper range Returns an integer. Preconditions menu String must be a string that contains the numbered options for the choices menu Title must be a string numOptions is an integer indicating the number of options for that menu NOTES: Be sure to test this function THOROUGHLY if the user enters a letter. or a number that is too small or too large, the function should print "Invalid choice -try again" and should reprint the menu String and ask the user to enter another choice Write a main program that does the following: o Calls the CreateMenu function 3 times to create 3 menuStrings (mainMenuStr check Menu Str, SavingsMenuStr) o Asks the user to enter the initial amount for their checking account-this will be the current balance for checking account o Asks the user to enter the initial amount for their savings account-this will be the current balance for their savings account o Calls getValidChoice, sending the mainMenu Str and "Main Menu" as parameters o As long as the choice isn't the Exit choiceExplanation / Answer
class MyAccount(object):
balance = 0
savingsAccount = 0
savingsAccountBalance = 0
def deposit(this):
print "Enter the Amount to Deposit"
x = input()
this.balance += x
print "Balance Available: " + str(this.balance)
def withdraw(this):
print "Enter the Amount to WithDraw"
x = input()
if(x<=this.balance):
this.balance -= x
print "Balance Available:" + str(this.balance)
else:
print "Not Enough Balance"
print "Available Balance : " + str(this.balance)
def savingDeposit(this):
print "Enter the Amount to Deposit"
x = input()
this.savingsAccount = x
this.savingsAccountBalance = x
print "Savings Balance Available: " + str(this.savingsAccountBalance)
def addInterest(this):
x = this.savingsAccountBalance
this.savingsAccountBalance = 1.01*x
print "Interest Earned :"+str(0.01*x)
def close(this):
x = this.savingsAccountBalance
print "Total Interest Earned : " +str(this.savingsAccountBalance-this.savingsAccount)
print "Ending Balance :" +str(this.savingsAccountBalance)
this.savingsAccountBalance = 0
this.savingsAccount = 0
def CreateMenu(optionList,menuTitle):
size = len(optionList)
# print optionList
listString = ""
for x in xrange(size):
listString = listString + str(x+1)+" "+ optionList[x]+" "
print menuTitle
print listString
return listString
def main():
mainMenuList = ["Checking","Savings","Print Balances","Exit"]
checkMenuList = ["Deposit","WithDraw","Return To Main Menu"]
savingsMenuList = ["Print total interest earned","Calculate Interest","Close Savings Account","Return To Main Menu"]
CreateMenu(mainMenuList,"mainMenyStr")
print "Enter the Option"
account = MyAccount()
val = input()
while(True):
if(val==1):
CreateMenu(checkMenuList,"CheckMenuStr")
val = input()
while(True):
if(val==1):
account.deposit()
elif(val==2):
account.withdraw()
elif(val==3):
break
CreateMenu(checkMenuList,"CheckMenuStr")
val = input()
elif(val==2):
CreateMenu(savingsMenuList,"savingsMenuStr")
val = input()
while(True):
if(val==1):
account.savingDeposit()
elif(val==2):
account.addInterest()
elif(val==3):
account.close()
elif(val==4):
break
CreateMenu(savingsMenuList,"savingsMenuStr")
val = input()
elif(val==3):
print "Balance : " +str(account.balance)
print "Savings Balance : " +str(account.savingsAccountBalance)
elif(val==4):
break
CreateMenu(mainMenuList,"mainMenyStr")
val = input()
if __name__ == "__main__":
main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.