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

Can some write this code for me? It is a single program BankAccount Class Design

ID: 3825172 • Letter: C

Question

Can some write this code for me? It is a single program

BankAccount Class

Design a BankAccount class that stores the account's annual interest rate and balance. the class constructor should accept the amount of the account's starting balance and Annual Interest Rate. The class should also have methods for subtracting the amount of withdrawal, add the amount of deposit, and adding the amount of monthly interest to the balance. The monthly interest rate is the annual interest rate divided by 12. To add the monthly interest to the balance, multiply the monthly interest rate by the balance, and add the result to the balance. ( this is compound interest )
Format output to 2 decimal places.

Test the class in 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, or prompt after each loop iteration to continue.

Set up Accumulator variables:  totalInterest, totalDeposits, totalWithdrawals

Prompt for starting balance and annual Interest Rate

Create a SavingsAccount object.

Loop through each of the following steps for each set of Input Data:

Prompt the user for the amount deposited into the account during the month. Use the class method to add this amount to account balance.

Prompt the user for the amount withdrawn from the account during the month. Use the class method to subtract the amount from the balance.

Use the class method to calculate the monthly interest.

After the last monthly interest calculation, display the ending balance, the total of deposits, the total of withdrawals, and the total interest.

class BankAccount
{
private:     double balance;      // Account balance  
double annualInterestRate;   

public:
BankAccount(double startBalance, double annualinterestrate);
void deposit(double amount);
void withdraw(double amount);
double getBalance();
void setBalance(double b);
double calculateInterest();   
};

Run the Program for this Program Data:

Starting Balance Annual Interest Rate Months Deposits/Withdrawals 1000.00 10% 6 Deposit 100.00 per month for first 3 months Withdraw 100.00 per month for last 3 months

Explanation / Answer

Program:;

import java.util.*;
import java.text.DecimalFormat;
public class HelloWorld
{
private double balance; // Account balance
private double annualInterestRate;   
private static DecimalFormat df = new DecimalFormat(".##"); //this is used to set double value upto 2 places

public HelloWorld(double startBalance, double annualinterestrate){
balance = startBalance;
this.annualInterestRate = annualinterestrate;
  
}
//this method is used to add deposit amount to balance amount
void deposit(double amount){
balance = balance+amount;
System.out.println("The total amount to be deposit is: "+ amount);
}
//this method is used to withdraw amount from balance amount
void withdraw(double amount){
balance = balance-amount;
System.out.println("The total amount to be withdraw is: "+ amount);
}
double getBalance(){
return balance;
}
void setBalance(double b){
this.balance = b;
}
// it calculate monthly interest of amount
double calculateInterest(){
double CI = balance*(1+(annualInterestRate/100));
double interest= CI-balance;
balance=CI;
return interest;
}

public static void main(String arr[]){
double totalInterest = 0;
Scanner sc = new Scanner(System.in);
System.out.println("enter Starting Balance of account: ");
double amount = sc.nextInt();
System.out.println("enter account's annual interest: ");
double interestRate = sc.nextInt();
System.out.println("enter amount to be deposit in account: ");
double depositAmount = sc.nextInt();
System.out.println("enter amount to be withdraw in account: ");
double withdrawAmount = sc.nextInt();
System.out.println("enter number of months: ");
int month = sc.nextInt();
HelloWorld h1 = new HelloWorld(amount,interestRate);
h1.deposit(depositAmount);
h1.withdraw(withdrawAmount);
for(int i=1;i<=month;i++){
double interest = h1.calculateInterest();
System.out.println("The calculated interest for month "+i+" is : "+df.format(interest));
totalInterest=totalInterest+interest;
}
System.out.println("The total interest is : "+df.format(totalInterest));
}
}

Output:-

enter Starting Balance of account:                                                                                                                                              

1000                                                                                                                                                                            

enter account's annual interest:                                                                                                                                                

10                                                                                                                                                                              

enter amount to be deposit in account:                                                                                                                                          

400                                                                                                                                                                             

enter amount to be withdraw in account:                                                                                                                                         

500                                                                                                                                                                             

enter number of months:                                                                                                                                                         

12                                                                                                                                                                              

The total amount to be deposit is: 400.0                                                                                                                                        

The total amount to be withdraw is: 500.0                                                                                                                                       

The calculated interest for month 1 is  : 90.0                                                                                                                                  

The calculated interest for month 2 is  : 99.0                                                                                                                                  

The calculated interest for month 3 is  : 108.9                                                                                                                                 

The calculated interest for month 4 is  : 119.79                                                                                                                                

The calculated interest for month 5 is  : 131.77                                                                                                                                

The calculated interest for month 6 is  : 144.95                                                                                                                                

The calculated interest for month 7 is  : 159.44                                                                                                                                

The calculated interest for month 8 is  : 175.38                                                                                                                                

The calculated interest for month 9 is  : 192.92                                                                                                                                

The calculated interest for month 10 is  : 212.22                                                                                                                               

The calculated interest for month 11 is  : 233.44                                                                                                                               

The calculated interest for month 12 is  : 256.78                                                                                                                               

The total interest is  : 1924.59