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

***In Java*** Given... public class Account { private String accountName; privat

ID: 3887600 • Letter: #

Question

***In Java***

Given...

public class Account {

private String accountName;   private static double INTEREST;   private double iRate;    private double balance;   .....

1. write a static bool method (with an array object parameter) that returns true if the sum of balances for Account objects from the parameter is greater than the INTEREST. if not, return false.

2. Write a method 'calculate' with a parameter newAcc. it stars by multiplying iRate and balance to get the interest. Next increase the value of balance by the interest rounded to nearest penny.

3.Write a constructor with parameters of a double and string. and have them set to the instance iRate and accountName

4. Finally, write a main method that creates three instances of Account. 1st - Doug with iRate of .3, 2nd - Jackson with iRate of .4, 3rd - Leeroy with iRate of .6 ... set the interest to 250 and calculate interest for the three instances.

Explanation / Answer

public class Account {

private String accountName;   

private double iRate;

private static double INTEREST;

private double balance;

public Account( double iRate,String accountName) {

super();

this.accountName = accountName;

this.iRate = iRate;

}

public String getAccountName() {

return accountName;

}

public void setAccountName(String accountName) {

this.accountName = accountName;

}

public double getiRate() {

return iRate;

}

public void setiRate(double iRate) {

this.iRate = iRate;

}

public double getBalance() {

return balance;

}

public void setBalance(double balance) {

this.balance = balance;

}

static boolean checkBalance(Account[] obj){

double totBalance=0.0;

for(int i=0;i<obj.length;i++){

totBalance+=obj[i].getBalance();

}

if(totBalance>INTEREST){

return true;

}

return false;

}

static void calculate(Account newAcc){

double interest=newAcc.getiRate()*newAcc.getBalance();

newAcc.setBalance(newAcc.getBalance()+interest);

System.out.println("Account Name:"+newAcc.getAccountName()+" Balance:"+newAcc.getBalance());

}

public static void main(String[] args) {

INTEREST=250;

Account acc1=new Account(0.3, "Doug");

Account acc2=new Account(0.4, "Jackson");

Account acc3=new Account(0.6, "Leeroy");

calculate(acc1);

calculate(acc2);

calculate(acc3);

}

}