Question

Write a program that does the following in order: 1. Ask user to enter a name...

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

Homework Answers

Answer #1
#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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Ask the user for integers. If the user did not enter an integer, ask again. (Type...
Ask the user for integers. If the user did not enter an integer, ask again. (Type Safe Input) Keep a running total of the intergers entered (sum). Once the user enters 0, stop looping. Print the sum of all the numbers. Enter an integer, 0 to stop> [fasdfsa] Invalid input. Enter an integer, 0 to stop> [231.342] Invalid input. Enter an integer, 0 to stop> [1] Enter an integer, 0 to stop> [2] Enter an integer, 0 to stop> [3]...
Use C++ Write a program that first reads in how many whole numbers the user wants...
Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the numbers just once each and the user can enter them...
Assembler lanaguage program   The program is to prompt the user to enter a number between 2...
Assembler lanaguage program   The program is to prompt the user to enter a number between 2 and 100. Reject any invalid user inputs and terminate the program if invalid inputs are entered. Print each even number from 2 to the user entered number. Sum these even numbers and print the sum. Print each odd number from 1 to the user entered number. Sum these odd numbers and print the sum. Exit the program when the output is complete. The output...
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Write a program that prompts the user to enter an integer number between 1 and 999....
Write a program that prompts the user to enter an integer number between 1 and 999. The program displays the sum of all digits in the integer if the input is valid; otherwise, it displays a message indicating that the integer is not between 1 and 999 and hence, is invalid. Name the program file Q1.cpp Example: if the user enters 12, sum of digits is 3. If the user enters 122, sum of digits is 5.
(8 marks) Write a program to ask user to input an integer and display the special...
Write a program to ask user to input an integer and display the special pattern accordingly. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use loop statements (for, while or do-while). Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("-"); // print # System.out.print("+"); // print + System.out.println(); // print a newline Your code must work exactly like the following example (the text in bold...
4) Write a java program where you will use while loop, where if condition is equal...
4) Write a java program where you will use while loop, where if condition is equal to 2 (or any other choice of your number) then it will break the while condition. Steps: 1) Declare variable int (any name) which is equal to zero 2) Declare while condition which variable int is less then equal to 10 3) Declare print out where the value of variable is the same name that you declared in step 1 4) Declare condition if...
Write a c++ program to pull a random number between 1-100 inclusive. Ask the user to...
Write a c++ program to pull a random number between 1-100 inclusive. Ask the user to guess the number. If the random number is higher than the guess, print "Higher". If the random number is less than the guess, print "Lower". If the random number is equal to the quess, print "Correct!". Create a variable to count the number of guesses and intitialize it to zero. int guesses=0; Increase this variable by 1 every time the user enters a new...
1) In Python Use a while loop to ask the user to enter a series of...
1) In Python Use a while loop to ask the user to enter a series of alphabets. The loop terminates when the user presses enter. Once the loop terminates, display the number of vowels and consonants entered by the user. Hint: keep a running count of the number of characters entered by the user. Keep a running count of the number of vowels. Total number of consonants = total number of characters - total number of vowels. Assume that the...
Write a complete C++ program asking the user to enter numbers one by one. User enters...
Write a complete C++ program asking the user to enter numbers one by one. User enters only whole numbers 0 and 10. Once the user enters 0, then the program should print sum of only odd numbers entered by user prior to 0. A valid scenario given below: Enter a number: 5 Enter a number: 3 Enter a number: 2 Enter a number: 3 Enter a number: 8 Enter a number: 0 Sum of the odd numbers you entered is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT