Write a program that does the following in order:
1. Ask user to enter a name
2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5”
3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5”
4. If the sum is greater than 0, print out the sum
5. If the sum is equal to zero, print out “Your account balance is zero”
6. If the sum is less than 0, print out “Your account is overdrawn” and the “negative amount”
7. Round all print values to 1 decimal place
Round your sum output to 2 decimal places.
Examples of the program’s inputs and outputs are shown below:
Enter your name: Belinda Patton
Enter your amount 1: 52
Enter your amount 2: 2
Enter your amount 3: -22
Enter your amount 4: 12
Enter your amount 5: 32
Your account balance is $76.00
Enter your name: Belinda Patton
Enter your amount 1: -52
Enter your amount 2: 2
Enter your amount 3: 22
Enter your amount 4: 12
Enter your amount 5: 28
Your account balance is zero.
Enter your name: Belinda Patton
Enter your amount 1: -52
Enter your amount 2: 2
Enter your amount 3: -22
Enter your amount 4: 12
Enter your amount 5: -32
Your account is overdrawn. The overdrawn amount is
$-92.00
#I am using python for this program.
# This will input the name of the program.
name = str(input('Enter your Name:'))
# Input amount_1.
amount_1 = int(input('Enter your amount 1:'))
# Input amount_2.
amount_2 = int(input('Enter your amount 2:'))
# Input amount_3.
amount_3 = int(input('Enter your amount 3:'))
# Input amount_4.
amount_4 = int(input('Enter your amount 4:'))
# Input amount_5.
amount_5 = int(input('Enter your amount 5:'))
# sum of all the amounts.
sum = amount_1 + amount_2 + amount_3 + amount_4 + amount_5
if sum > 0:
# printing the sum with 2 decimal places.
print('Your Account balance is ${:0.2f}'.format(sum))
if sum == 0:
print('Your Account balance is zero.')
if sum < 0:
print('Your account is overdrawn. The overdrawn amount is ${:0.2f}'.format(float(sum)))
I have added the code snippet and a screenshot of the executed program. If you have any doubts please let me know. If you like the answer please let me know.
Get Answers For Free
Most questions answered within 1 hours.