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...
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?
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 program that calculates the mean, median and mode of a given array in the...
Write a program that calculates the mean, median and mode of a given array in the following manner: i) Write three functions mean (), median () and mode () that calculates the mean, median and mode of an array. ii) Using these functions write a program that calculates all the three above mentioned values for two different arrays A and B where A is an array that contains the number of hours spent by a person each day for playing...
Write a program that contains a function that takes in three arguments and then calculates the...
Write a program that contains a function that takes in three arguments and then calculates the cost of an order. The output can be either returned to the program or as a side effect. 1. Ask the user via prompt for the products name, price, and quantity that you want to order. 2. Send these values into the function. 3. Check the input to make sure the user entered all of the values. If they did not, or they used...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading: 13505.2 Enter ending odometer reading     : 13810.6 You traveled 305.40 miles. At $ 0.35 per mile, your reimbursement is $ 106.89. The values in red color are inputs for the program. The values in blue color are results of expressions.
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...
In C++, Write a program that calculates pay for either an hourly paid worker or a...
In C++, Write a program that calculates pay for either an hourly paid worker or a salaried worker. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are paid their regular salary plus any bonus they may have earned. The program should declare two structures for the following data: Hourly Paid: HoursWorked HourlyRate Salaried: Salary Bonus The program should also declare a union with two members. Each member should be a structure...
Write a program that prompts user to enter integers one at a time and then calculates...
Write a program that prompts user to enter integers one at a time and then calculates and displays the average of numbers entered. Use a while loop and tell user that they can enter a non-zero number to continue or zero to terminate the loop. (Switch statement) Write a program that prompts user to enter two numbers x and y, and then prompts a short menu with following 4 arithmetic operations: Chose 1 for addition Chose 2 for subtraction Chose...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT