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
A blood bank maintains two tables - DONOR, with information about people who are willing to donate blood and ACCEPTOR, with info
Kipish [7]

Answer:

The sql query is given below.

Since we need to count of males and females for a particular blood group, we put xxx for the blood group.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors,

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

Explanation:

The clauses in the query are as follows.

1. SELECT: all the columns required in the output are put in this clause.

2. FROM JOIN ON: the table(s) from which the above columns are taken are put in this clause.

3. WHERE: any condition required to filter the output is put in this clause.

The query is explained below.

1. Find the number of male donors. Number of anything can be found using COUNT() function. A query is required since gender is included in deciding the type of donor.

2. The query is defined to find number of male donors as follows.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "M%"; )

3. In the previous query, LIKE operator is used since it is not defined what value is stored for male donors.

4. Similarly, the query to find the number of female donors is formed.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "F%"; )

5. Next, the final query is formed as follows.

SELECT: both COUNT() functions will come here.

FROM: table name

WHERE: specific blood group will be put here

GROUP BY: this clause is optional and is not used in this query.

HAVING: this clause is optional and is not used in this query.

6. The query after putting all clauses is shown below.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%"),

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%")

FROM DONOR

WHERE BG = xxx;

7. Alias is used in the above query for each column to get the final query.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors, COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

7 0
3 years ago
Digital and analog audio recordings have pros and cons. Do you think the pros of digital recordings outweigh the cons and theref
Debora [2.8K]

Digital vs Analog Audio is completely personal preference and there is no clear winner on which is better.

But there are some pros and cons about both, Analog sometimes distorts when playing and can be easily scratched and ruins the grooves. Analog is believed to be the true representation of the sound when it was recorded. Digital is not the actual recording of the sound, it's actually a combination of binary code. It is also sometimes mixed or remastered in Digital and sounds a bit different to make it sound better. It also depends on the system you are listening it from. You could have a horrible Digital system its playing through and an amazing Analog system playing, of course the Analog system will sound better in that case. Some believe that Digital is on par to overtake Analog in the "true picture of sound" category but some also say Analog will forever be the best at playing sound and Digital will always be the alternative.

But, in the end it's all personal preference and the pros and cons don't overweigh to make one better than the other.

6 0
3 years ago
Which of the following are not valid assignment statements? A) total = 9;
never [62]

Answer:

The correct option for the given question is option(b) i.e 72 = amount;

Explanation:

In the option(a) the total variable store the value 9 which is a valid assignment  

In the option(b) 72 is not a variable because the variable will never start with a numeric number. Therefore it is not a valid assignment statement.

In the option(c) the yourAge variable store the value of myAge variable which is a valid assignment.

So correct answer is an option(b).

7 0
3 years ago
What can you say about 3s in 43,335?
Greeley [361]
That 43,335 is divisible by 3 giving a whole number as result
6 0
3 years ago
Read 2 more answers
Which payment type is best if you are trying to stick to a budget?
gavmur [86]
Debit is the best payment type
3 0
2 years ago
Other questions:
  • Project Description The Department plans to purchase a humanoid robot. The Chairman would like us to write a program to show a g
    15·1 answer
  • What was the major sign that lead Professor Shiller to predict the crash of the housing market​
    6·1 answer
  • Pre-made, copyright-free illustrations are called __________. apps clip art graphic design stock photos
    6·1 answer
  • How many comparisons will be done to find 8 in this list using a linear search?
    8·1 answer
  • Old systems can be useful when designing new computer software.<br> True or False
    7·2 answers
  • Write a method named addCommas that accepts a string representing a number and returns a new string with a comma at every third
    10·1 answer
  • A leading global vendor of computer software, hardware for computer, mobile and gaming systems, and
    5·1 answer
  • A(n) _____ is a computerized system by which subscribers are able to communicate to all other subscribers by sending a transmiss
    5·1 answer
  • Which automatic startup option should you choose when windows' startup fails immediately after installing a new driver but befor
    5·1 answer
  • Discussion Topic
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!