Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

ID: 3837918 • Letter: W

Question

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: Ask the user for the total amount deposited into the account during that month and add it to the balance. Do not accept negative numbers. Ask the user for the total amount withdrawn from the account during that month and subtract it from the balance. Do not accept negative numbers or numbers greater than the balance after the deposits for the month have been added in. 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 amount for the month. This amount should be added to the balance. After the last iteration, the program should display a report that includes the following information: starting balance at the beginning of the three-month period total deposits made during the three months total withdrawals made during the three months total interest posted to the account during the three months final balance Large and readable screen shot of your input/output window for below input sets (don't group multiple screen shots in single picture, paste each as separate in your word doc) Starting balance: 26000 Annual interest rate(%): 3.25 Month 1: Deposit 4500, Withdrawal 3400 Month 2: Deposit 3700, withdrawal 2800 Month 3: Deposit 4100, Withdrawal 3500 In order to make sure your program works correctly compare the output of your program with the numbers below for the given sample input: Starting balance: 26000.00 deposits within 3 months: 12300 withdrawals within 3 months: 9700 Amount of Interest within 3 months: 223.76 month 1 ending balance: $27171.91 month 2 ending balance: $2814672 Note as stated in the problem: Annual interest rate of 3.25 is percentage interest is computed on the average of starting and ending balance for each month.

Explanation / Answer

The below code will satisfy the given requirement as follows:-
----------------------------------------------------------------------------------------

package Chegg;
import java.util.Scanner;
public class Simple_Interest
{
public static void main(String args[])
{
float StartBal,AI,MonthBal,MonthDep,FinalBal,temp,TotDep,TotWithdraws;
Scanner s = new Scanner(System.in);
System.out.print("Enter the Starting Balance : ");
StartBal = s.nextFloat();
System.out.print("Enter the anuual interest rate : ");
AI = s.nextFloat();
FinalBal=StartBal;
for(int i=1;i<=3;i++) //iteration for every month
{
  
System.out.println("Enter the deposite made in month "+i+" : ");
do
{
System.out.println("Enter a positive number"): //do while loop is used to ensure the enterd number is a positive number
temp = s.nextFloat();
  
}while(temp<0)
TotDep=TotDep+temp;
FinalBal=FinalBal+temp;
System.out.println("Enter the withdraws made in month "+i+" : ");
do //do while loop is used to ensure the enterd number is a positive and greater than the current balance
{
System.out.println("Enter a positive and greater than the current Balance"):
temp = s.nextFloat();
}while(temp<0 && temp>FinalBal)
TotWithdraws=TotWithdraws+temp;
FinalBal=FinalBal-temp;
  
temp=AI/12; //calculating the anual intrest and storing to AI
AI=(FinalBal*(temp*3)/100
FinalBal=FinalBal+AI;
}
  
System.out.println("Starting Balance:"+StartBal);
System.out.println("Deposits within 3 months:"+TotDep);
System.out.println("WithDrawals within 3 months :"+TotWithdraws);
System.out.println("Amount of interest within 3 months:"+AI);
System.out.println("Final Balance:"+FinalBal);
}
}

Output:-
--------
Starting Balance:26000.00
Deposits within 3 months:12300
WithDrawals within 3 months:9700
Amount of interest within 3 months:223.76
Final Balance:28823.76

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote