Question: userid = dmr password = 1234 balance = 100.0 # TASK 1 # Ask user if they have an account and expect 'Y' or 'N'
userid = "dmr"
password = 1234
balance = 100.0
# TASK 1
# Ask user if they have an account and expect 'Y' or 'N' as input
# if user enter N request an id and password and assign them to their
# corresponding variables accordingly
x = input("Enter Y or N")
if(x == 'N'):
userid = input(Enter your userid)
password = input(Enter your password)
else:
userid = "dmr"
password = 1234
# TASK 2
# Prompt user to enter their ID and PIN consecutively and store them
# in two temporary variables (e.g temp_userid)
temp_userid = input("Enter your User ID")
temp_userPIN = input("Enter your PIN")
menu = 0
in_menu_input = 0
# TASK 3
# Check wheter given temporary userid and password is equal to ones
# which are stored in the userid and password. If they are equal print
# a menu on the console like shown below otherwise print 'Invalid Credentials'
# 1-Withdraw
# 2-Deposit
# 3-View Balance
# 4-Press any key to exit
# Then expect user to enter a number listed in the menu
# You are supposed to implement listed functions and check entered
# input from the user then realize described action.
# Task specific requirements:
# Withdraw: You are supposed to ask amount to withdraw to user and store it in
# a variable, if user enters a value other than 0 check if user has sufficient funds
# in their account realize necessary operation on users balance
# and print a message if task is completed or failed. Such as;
# e.g.
# You withdraw: 10
# Your balance: 20
# or
# Insufficient funds...
# Deposit: Ask user amount to deposit like "Please put deposit amount in..." and
# check entered amount for any possible invalid inputs that may cause malfunction of
# your program. (e.g. negative inputs) then realize requested action on balance.
# Balance: Print balance on the screen
if(id == temp_userid and password == temp_userPIN):
print("1-Withdraw,2-Deposit,3-View Balance,4-Press any key to exit /n")
if(in_menu_input == 1):
menu = menu + 1
withdrawal_amount = int(input("Enter amount to withdraw"))
if(withdrawal_amount == 0):
print("You cannot withdraw 0 dollar")
elif(withdrawal_amount > balance):
print("Insufficient funds")
else:
print("Successful operation,your current amount is",balance- withdrawal_amount)
balance = balance - withdrawal_amount
if(in_menu_input == 2):
menu += 2
deposit = int(input("Please put deposit amount in"))
if(deposit < 0):
print("You can't deposit negative money")
else:
print("Successful operation,your current amount is",balance+deposit)
balance = balance + deposit
if(in_menu_input == 3):
menu += 3
print(balance)
else:
print("Invalid Credentials)
I couldn't figure out how to implement menu = 0 and maybe there are some bugs in my code,indentations doesn't properly copied in here.Goal is to write this without any function and with if-else statements(Python)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
