d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Python Help
Add Reply New Topic New Poll
Member
Posts: 53,434
Joined: Oct 14 2009
Gold: 1,014.14
Oct 7 2018 01:40am
Just started an intro class and need help with this project..


needing to ask the user for the initial balance
Amounts of each deposit,
Amounts of each debit.

Allow the user to process as many transactions as desired; handling input deposits and debits in any order.


# Original Bank balance
initial = int(input("Welcome! Please enter your initial bank balance: "))
initial = int(initial)

balance = input("Please Enter your deposit: ")
balance = int(balance)


print("Do you wish to add another deposit? ")
strMore = input("Enter Y or N: ")
if (strMore == "Y") or (strMore == "y"):
print("Please enter your deposit: ")


addbalance = initial + balance

print("Your initial balance with your deposit is", addbalance)

input("\n\nPress the Enter key to exit")


If you can help! Let me know. :love:
Member
Posts: 16,662
Joined: Nov 24 2007
Gold: 15,245.00
Trader: Trusted
Oct 7 2018 12:27pm
# Original Bank balance
initial = input("Welcome! Please enter your initial bank balance: ") # you had a double conversion into integer
initial = int(initial)

answer = True

while answer == True : # this will be repeated, until the user decides otherwise.
[tab] print("\n Your balance is currently : $", initial)

[tab] answer = input("\n Do you want to make a deposit or a withdraw (Y/N) ?")
[tab] if (answer == "Y") or (answer == "y") :
[tab][tab] balance = input("\n Please Enter your deposit (positive number) or withdraw (negative number) : ")
[tab][tab] balance = float(balance) # float(X) tries to convert X into a float (floating point number). This allows you to add $3.95 for example.
[tab][tab] initial = initial + balance
[tab][tab] answer = True

print("\n Thanks, and goodbye !")
Member
Posts: 53,434
Joined: Oct 14 2009
Gold: 1,014.14
Oct 7 2018 04:10pm
The issue I'm having is that it's asking for deposit and debits

Write a Python program to balance a bank debit account.
The program needs to ask the user for
the initial balance,
the amounts of each deposit, and
the amounts of each debit.
Allow the user to process as many transactions as desired; handle input deposits and debits in any order.



# Original Bank balance
initial = int(input("Welcome! Please enter your initial bank balance: "))
initial = int(initial)

print("\n Your balance is: $", initial)

deposit = input("Enter your deposit: ")
deposit = int(deposit)

debit = input("Enter your debits: ")
debit = int(debit)


trying to make it now

"Do you wish to add another deposit?"
"Do you wish to add another debit?"

(in a loop)

then just add everything together and a prompt message at the end like print("\n Thanks, and goodbye !")

This post was edited by Plaguel0rd on Oct 7 2018 04:16pm
Member
Posts: 16,662
Joined: Nov 24 2007
Gold: 15,245.00
Trader: Trusted
Oct 8 2018 12:52pm
The loop I've post is using a "while answer == True" condition. Doesn't it work ?

You can easily change some lines in that loop, if you want to display a specific message : "Do you wish to add another deposit?" or "Do you wish to add another debit?".

Just drop me a pm if there's a problem on that part.

Good luck.
Member
Posts: 53,434
Joined: Oct 14 2009
Gold: 1,014.14
Oct 8 2018 07:32pm
Quote (feanur @ Oct 8 2018 02:52pm)
The loop I've post is using a "while answer == True" condition. Doesn't it work ?

You can easily change some lines in that loop, if you want to display a specific message : "Do you wish to add another deposit?" or "Do you wish to add another debit?".

Just drop me a pm if there's a problem on that part.

Good luck.


It does! I copied it wrong. This is what i ended up with

initial = input("Welcome! Please enter your initial bank balance: ")
initial = int(initial)

answer = True

while answer == True :
print("\n Your balance is currently : $", initial)

answer = input("\n Do you want to make a deposit or debit (Y/N) ?")
if (answer == "Y") or (answer == "y"):
dep1 = input("Enter your deposit: ")
dep1 = int(dep1)
debit = int(input("Enter your debits: "))
debit = int(debit)
balance = float(dep1 - debit)
initial = initial + balance
answer = True
print("\n\nThanks! Your deposit was: $", dep1, "Your debit was: $",debit,)

print("\n Thanks, and goodbye !")

Member
Posts: 722
Joined: May 26 2006
Gold: 0.00
Oct 9 2018 02:06pm
Solved?
Go Back To Homework Help Topic List
Add Reply New Topic New Poll