Question

In: Computer Science

Write a program that calculates the balance of a savings account at the end of a...

Write a program that calculates the balance of a savings account at the end of a three month period. It should ask the user for the starting balance and the annual interest rate. A loop should then iterate once for every month in the period, performing the following:

  1. Ask the user for the total amount deposited into the account during that month. Do not accept negative numbers. This amount should be added to the balance.
  2. Ask the user for the total amount withdrawn from the account during that month. Do not accept negative numbers or numbers greater than the balance after the deposits for the month have been added in.
  3. Calculate the interest for that month. The monthly interest rate is the annual interest rate divided by 12. Multiply the monthly interest rate by the average of that month's starting and ending balance to get the interest for that month. This amount should be added to the balance.

After the last iteration, the program should display a final report that includes the following information:

  • Starting balance at the beginning of the last three-month period
  • Total deposit made during the last three-month period
  • Total withdrawal made during the last three-month period
  • Total interest posted to the account during the three months
  • Final balance

IN PYTHON PLEASE!!

Solutions

Expert Solution

Solution:

Note: Please refer the screenshot for indentation.

Code implementation:

balance=int(input("Enter Starting balance: "))
print(balance) #prints balance entered by the user.
annual_ir=int(input("Enter Annual interest rate: "))
print(annual_ir) # prints annual_ir entered by the user.
i=0 #iteration variable.
while(i<3):
print()
print("Month:",end=" ")
print(i+1)
i+=1
month_starting_balance=balance # month_starting_balance
print("Starting balance:",end=" ")
print(month_starting_balance)
amount_deposit=int(input("Enter deposit amount: "))
print(amount_deposit) # prints amount_deposit
while(amount_deposit<0): # checks for negative value.
amount_deposit=int(input("Enter deposit amount: "))
print(amount_deposit)
balance+=amount_deposit # adds amount deposited.
print("Amount deposited:",end=" ")
print(amount_deposit)
amount_withdraw=int(input("Enter withdraw amount: "))
print(amount_withdraw) #prints amount_withdrawn
# checks for negative and amount greater than balance.
while(amount_withdraw<0 or amount_withdraw>balance):
amount_withdraw=int(input("Enter withdraw amount: "))
print(amount_withdraw)
print("Amount withdrawn:",end=" ")
print(amount_withdraw)
balance-=amount_withdraw # subtracts the withdrawn amount from balance.
month_ending_balance=balance
monthly_interest=annual_ir/12 #monthly Interest.
interest_for_month=((month_starting_balance+month_ending_balance)/2)*monthly_interest
print("Ending balance:",end=" ")
print(month_ending_balance) # displays month end balance.
print("Interest posted:",end=" ")
print(interest_for_month) # displays interest for each month.
balance+=interest_for_month
print("Final balance:",end=" ")
print(balance) # displays balance for each month.

Code screenshot:

Code input and output screenshot:



  
  
  
  


Related Solutions

Write a program that calculates the balance of a savings account at the end of a...
Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, and the number of months that have passed since the account was established. A loop should then iterate once for every month, performing the following: Ask the user for the amount deposited into the account during the month. (Do not accept negative numbers.) This amount should be added...
using C++ 23. Savings Account Balance Write a program that calculates the balance of a savings...
using C++ 23. Savings Account Balance Write a program that calculates the balance of a savings account at the end of a three- month period. It should ask the user for the starting balance and the annual interest rate. A loop should then iterate once for every month in the period, performing the following steps: A) Ask the user for the total amount deposited into the account during that month and add it to the balance. Do not accept negative...
Create a Java Program to show a savings account balance. using eclipse IDE This can be...
Create a Java Program to show a savings account balance. using eclipse IDE This can be done in the main() method. Create an int variable named currentBalance and assign it the value of 0. Create an int variable named amountToSaveEachMonth. Prompt "Enter amount to save each month:" and assign the result to the int variable in step 2. Create an int variable name numberOfMonthsToSave. Prompt "Enter the number of months to save:" and store the input value into the variable...
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
If $30,000 is deposited in a savings account at the end of each year and the...
If $30,000 is deposited in a savings account at the end of each year and the account pays interest of 5% compounded annually, what will be the balance of the account at the end of 10 years?
Write a program that calculates the salary of employees. The program should prompt the user to...
Write a program that calculates the salary of employees. The program should prompt the user to enter hourly rate and number of hours of work a day. Then, the program should display the salary daily, bi-weekly (5 days a week), and monthly. Sample program: Enter your hourly rate: >>> 20 Enter how many hours you work a day: >>> 8 Your daily salary is: $160 Your bi-weekly salary is: $1600 Your monthly: $3200
Suppose that you deposit $871 in a savings account at ProsperityBank at the end of...
Suppose that you deposit $871 in a savings account at Prosperity Bank at the end of each of the next 7 months. You plan to leave these contributions and any interest earned in the account until 7 months are up. The interest rate is 2.47% per month. What is the future value of your account at the end of the holding period? Do not round at intermediate steps in your calculation. Round your final answer to the nearest penny. Do...
Program Name: Divisible. Write a program that calculates the number of integers in a range from...
Program Name: Divisible. Write a program that calculates the number of integers in a range from 1 to some user-specified upper bound that are divisible by 3, the sum of those integers, and the number and sum of those integers not divisible by 3. Your program must display meaningful output which includes: the selected upper bound number of integers divisible by 3 sum of integers divisible by 3 number of integers not divisible by 3 sum of integers not divisible...
Program Name: Divisible. Write a program that calculates the number of integers in a range from...
Program Name: Divisible. Write a program that calculates the number of integers in a range from 1 to some user-specified upper bound that are divisible by 3, the sum of those integers, and the number and sum of those integers not divisible by 3. Your program must display meaningful output which includes: the selected upper bound number of integers divisible by 3 sum of integers divisible by 3 number of integers not divisible by 3 sum of integers not divisible...
Write a multithreaded program that calculates various statistical values for a list of numbers. This program...
Write a multithreaded program that calculates various statistical values for a list of numbers. This program will be passed a series of numbers on the command line and will then create three separate worker threads. One thread will determine the average of the numbers, the second will determine the maximum value, and the third will determine the minimum value. For example, suppose your program is passed the integers 90 81 78 95 79 72 85 The program will report The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT