1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lapo4ka [179]
2 years ago
6

You’ve been hired to help a bank automate their deposit/withdrawal system! Your task is to write a Python program that interacts

with a customer in order to process a deposit or withdrawal.
Assume the customer has an initial balance of $1000 (you should store the number 1000 in a variable). Then, ask the user two things:

Whether they want to make a deposit or withdrawal

For this step, they should type a deposit or withdrawal, depending on what they want to do. It needs to be the exact spelling, including capitalization!
How much money they want to deposit or withdraw

For this step, they should enter an integer.
Then, your program should use an if/elif/else statement to do the following:

If the customer is making a deposit, add the amount to their balance.
If the customer is making a withdrawal, subtract the amount from their balance.
If the customer typed something other than "deposit" or "withdrawal", print "Invalid transaction.".
In this case, the customer’s final balance is just the same as their initial balance.
Finally, your program should use an if/else statement to do the following:

If the customer’s final balance would be negative (less than zero), tell them "You cannot have a negative balance!".
Otherwise, report their final balance.
Here are some examples of what running your program should look like:

Example 1:

Deposit or withdrawal: withdrawal
Enter amount: 500
Final balance: 500

Example 2:

Deposit or withdrawal: withdrawal
Enter amount: 1500
You cannot have a negative balance!

Example 3:

Deposit or withdrawal: deposit
Enter amount: 500
Final balance: 1500

Computers and Technology
1 answer:
mixer [17]2 years ago
4 0

Answer: See below

Explanation:

<u>Description:</u> In this program, read-option from the user and based on that, perform the operation. And display the balance if the balance is negative.

<u>transactions.py</u>

balance = 1000

#read options from the user

option = input("Deposit or withdrawal: ")

amount = 0

#check if option is a withdrawal

if option == 'withdrawal':

amount = int(input("Enter an amount: "))

balance = balance - amount

#check option is deposit

elif option == 'deposit':

amount = int(input("Enter an amount: "))

balance = balance + amount

else:

print("Invalid transaction.")

#check balance is less than 0 (negative)

if balance < 0:

print("You cannot have a negative balance!")

else:

print("Final balance:",balance)

You might be interested in
Write a converter program for temperatures. This program should prompt the user for a temperature in Celsius. It should then con
Aleksandr [31]

Answer:

c = float(input("Enter the temperature in Celsius: "))

f = c * 1.8 + 32

print("The temperature in Fahrenheit: " + str(f))

k = (f - 32) / 1.8 + 273.15

print("The temperature in Kelvin: " + str(k))

Explanation:

*The code is in Python.

Ask the user to enter the temperature in Celsius

Convert the Celsius to Fahrenheit using the conversion formula and print it

Convert the Fahrenheit to Kelvin using the conversion formula and print it

3 0
3 years ago
________ returns the last character in a StringBuilder variable named strBuf? Select one: A. strBuf.charAt(strBuf.length() - 1)
Lunna [17]

Answer:

A

Explanation:

strBuf.charAt(strBuf.length() - 1)

4 0
3 years ago
What are general purpose computer and special purpose computer?​
icang [17]

Answer:

General purpose computers are designed to be able to perform variety of tasks when loaded with appropriate programs, while special purpose computers are designed to accomplish a single task.

3 0
3 years ago
Read 2 more answers
What is the energy conversion of solar water heaters?
Gelneren [198K]
A liquid-to-liquid heat exchanger uses a heat-transfer fluid that circulates through the solar collector, absorbs heat, and then flows through a heat exchanger to transfer its heat to water in a storage tank. Heat-transfer fluids, such as antifreeze, protect the solar collector from freezing in cold weather.
7 0
3 years ago
Which role involves designing and creating advertisements for marketing purposes?
satela [25.4K]

advertising designers

5 0
3 years ago
Other questions:
  • Discuss 2D gameplay and how new platforms such as cell phones are taking advantages of this renewed market
    5·1 answer
  • Match the items.
    15·1 answer
  • Which occupation requires certification by the state?
    15·2 answers
  • 2. Use inheritance to create a hierarchy of Exception classes -- EndOfSentenceException, PunctuationException, and CommaExceptio
    6·1 answer
  • __________ was awarded the Nobel Prize in physics forhis work on the photoelectric effect.
    13·1 answer
  • Please help!!
    8·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    15·2 answers
  • An algorithm that could execute for an unknown amount of time because it depends on random numbers to exit a function may:______
    13·1 answer
  • Which country was the first in the world to launch a mass media campaign in response to population growth?
    14·1 answer
  • In additon to setting up services, what other tasks does a sysadmin have to keep in mind? check all that apply.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!