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...
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?
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...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT