Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 -The ATM Code works BUT I got points off for the following. I just cannot see how to put her suggestions in without

Python 3 -The ATM Code works BUT I got points off for the following. I just cannot see how to put her suggestions in without messing up my code. **Your functions did not contain any input parameters. You want to prompt for the input (deposit amount or withdrawal amount) and send that into the function when you call it. Here are some examples: deposit(deposit_amount): or withdraw(withdrawal_amount): Make sure your comments use the keywords 'input parameters' where you have used them.**

import sys

import sys

#account balance account_balance = float(500.25)

#<--------functions go here--------------------> # Define printbalance function. It is returning the current balance with 2 decimal places. def printbalance(): print("Your current balance is") return account_balance

#Define the deposit function. Allows the user to enter deposit amount. def deposit(): #Input for deposit amount. deposit_amount = float(input("How much would you like to deposit today? ")) #Balance calculation in c = a + b format. balance = account_balance + deposit_amount #Output of deposit amount and current balance amount. print("Deposit was $%.2f, current balance is $%.2f" %(deposit_amount,balance)) #Define the withdrawal function. Allows the user to enter the withdrawal amount. def withdraw(): #Input for withdrawal amount withdrawal_amount = float(input("How much would you like to withdraw today? ")) #This checks if the withdrawal amount is greater than the balance. if(withdrawal_amount > account_balance): #If so, this the output will tell the user that the amount is greater #than their account balance. print("$%.2f is greater than your account balance of $%.2f " %(withdrawal_amount,account_balance)) else: #Balance calculation in c = a - b format. balance = account_balance - withdrawal_amount #If not, the output will state the amount and the current account balance. print("Withdrawal amount was $%.2f, current balance is $%.2f" % (withdrawal_amount, balance)) #The user input is entered and an if/else conditional statement is used to #call the function based on user input. userchoice = input("What would you like to do? ")

#Deposit function is called. if (userchoice == 'D'): deposit()

#Withdrawal function is called. elif userchoice == 'W': withdraw() #Printbalance function is called. elif userchoice == 'B': balance = printbalance() #Outputs the balance in float format. print('{:.2f}'.format(balance)) else: #If user selects any other choice, this will be the output. print("Thank you for banking with us.") #The program is ended. sys.exit()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

Describe and provide examples of dependent and independent demand.

Answered: 1 week ago