def atmTransaction(): atmType = str(input("Would you like to deposit or withdraw money?")) if atmType == "withdraw": atmWithdrawMoney = int( input("How much money would you like to withdraw?")) if atmWithdrawMoney <= Balance.getBalance() and atmWithdrawMoney > 0: Balance.amountToDeduct(atmWithdrawMoney) print("You have successfully withdrew $", atmWithdrawMoney) Menu.displayMenu() else: print( "You cannot withdraw that amount of money. Please enter a number within your balance." ) atmTransaction() elif atmType == "deposit": atmDepositMoney = int( input("How much money would you like to deposit?")) if atmDepositMoney <= 500000 and atmDepositMoney > 0: Balance.amountToAdd(atmDepositMoney) print("You have successfully deposited $", atmDepositMoney) Menu.displayMenu() else: print( "You cannot deposit that amount of money. Please enter a number within $1-$500,000." ) atmTransaction() else: print("You can only deposit or withdraw money. Please try again.") atmTransaction()
def buyStock(): print("Check out our latest stocks!") ticker = str(input("Please enter your ticker")) quantity = int(input("How much stocks would you like to buy?")) stock_price = 100 print("The current stock price is ", stock_price) if quantity > 100: print( "You are purchasing more than 100 stocks so you get a 5% discount." ) stock_price = stock_price - stock_price * 0.05 if quantity > 350: print("sorry, but you cannot buy more than 350 stocks.") else: amount = (stock_price * quantity) Balance.amountToDeduct(amount) print("You have just purchased ", ticker, " and the quantity = ", quantity, " total amount paid is ", amount) print("Your account balance is: ", Balance.getBalance()) Menu.displayMenu()
def withdrawMoney(): withdrawAmount = int(input("How much money would you like to withdraw? \n")) print("You are withdrawing: ", withdrawAmount) if Balance.getBalance() < withdrawAmount: print("Error: You cannot withdraw that amount of money. You must withdraw less than or equal to the amount of money you have. ") sleep(1) withdrawMoney() elif withdrawAmount <= 0: print("Error: You cannot withdraw that amount of money. You must withdraw between your amount and zero. ") sleep(1) withdrawMoney() elif withdrawAmount == str: print("Error: You cannot withdraw that amount. Please enter a number.") sleep(1) withdrawMoney() elif withdrawAmount <= Balance.getBalance() and withdrawAmount > 0: Balance.amountToDeduct(withdrawAmount) print("You have successfully withdrew $", withdrawAmount) print("Your new balance is ", Balance.getBalance()) sleep(1)
def donateMoney(): global donateAmount donateAmount = int(input("How much money would you like to donate?")) if donateAmount > 0 and donateAmount < 500000: if donateAmount <= Balance.getBalance(): place1 = "Covid-19 Relief" place2 = "Pennies for the Poor" place3 = "Cancer Research Center" donatePlace = str(input("What charity would you like to donate to?\n" "1. Covid-19 Relief\n" "2. Pennies for the Poor\n" "3. Cancer Research Center\n")) if donatePlace == "1": Balance.amountToDeduct(donateAmount) print("You have successfully donated $ ", donateAmount," to ", place1, " charity.") elif donatePlace == "2": Balance.amountToDeduct(donateAmount) print("You have successfully donated $ ", donateAmount," to ", place2, " charity.") elif donatePlace == "3": Balance.amountToDeduct(donateAmount) print("You have successfully donated $ ", donateAmount," to ", place3, " charity.") else: print("Please enter an available charity to donate to!") donateMoney() else: print("You do not have enough money in your account to donate. You have $", Balance.getBalance(), " but you want to donate $", donateAmount) donateMoney() else: print("You cannot donate that amount of money. Please try again within the range of $0-$500,000.") donateMoney()
def startShop(): enter = str(input("Would you like to enter the shop?")) if enter == "yes" or enter == "y": print("You have entered the store. Here, you can buy merch and piggy banks!") type1 = str(input("What would you like to buy:\n" "1. Merchandise\n" "2. Piggy Banks\n" "3. Checkbooks\n")) if type1 == "1": choice1 = str(input("What type of merchandise would you like to buy?\n" "1. Sweaters\n" "2. Hats\n" "3. T-Shirts\n")) if choice1 == "1": buy = str(input("This is $20. Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(20) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() if choice1 == "2": buy = str(input("This is $7. Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(7) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() if choice1 == "3": buy = str(input("This is $15. Would you still like to buy it?")) Balance.amountToDeduct(15) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() elif type1 == "2": color = str(input("What color Piggy Bank would you like to buy? We have blue, red, and green.")) if color == "blue": buy = str(input("This is $10. Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(10) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() if color == "red": buy = str(input("This is $10. Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(10) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() if color == "green": buy = str(input("This is $10. Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(10) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() elif type1 == "3": texture = str(input("What texture would you like your checkbook to be? We have 1. standard, 2. classic, and 3. new textures.")) if texture == "1": price = 10 buy = str(input("This is $"+ str(price) +" Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(price) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() if texture == "2": price = 15 buy = str(input("This is $" + str(price) + " Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(15) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() if texture == "3": price = 20 buy = str(input("This is $" + str(price) + " Would you still like to buy it?")) if buy == "yes" or buy == "y" or buy == "Yes" or buy == "Y": Balance.amountToDeduct(10) print("You have successfully bought this product. Thank you and have a nice day.") Menu.displayMenu() else: print("Ok, that's fine.") startShop() else: print("Ok. Have a nice day!") Menu.displayMenu()