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

Please modify this Savings account which has a balance and monthly interest rate

ID: 3769803 • Letter: P

Question

Please modify this Savings account which has a balance and monthly interest rate. Deposits can occur anytime but withdrawals are limited to 3 per month. If a withdrawal occurs after 3 have been performed within a 30 day time span, a 2% of balance penalty is automatically taken out of the savings balance.

--------------------------------------------------------------------------------------

package bankapp;

public class SavingAccount extends BankAccount {

   // create a interest field with default value 1%

   private double interest = 0.0;

   SavingAccount(String name, double balance, int dateCreated) {

       super(name, balance);

       this.accountType = "saving";
   }
    @Override
   public double getProjectAmount()
   {
       return projectAmount;
   }
      public double getBalance()
   {
     return balance;
   }
   public void setBalance ( double val)
   {
       balance = val;
   }
    /**
     * @param amount
     */

   public void projectAmount( double amount)
   {
       double newBalance = balance * amount;
   }
   // conditional withdraw
   //

   @Override
    public void withdraw( double amount)
   {
    double newBalance = balance - amount;
    balance = newBalance;
   }
    @Override
   public void deposit(double amount) {

       if (amount <= 0) {

           System.out.println("Amount to be depsited should be positive");

       } else {

           //new balance includes interest

           balance = balance + amount + (amount * interest) / 100;

           transactions[numOfTransactions] = amount;

           transactionsSummary[numOfTransactions] = "$"

                   + Double.toString(amount) + "was deposited.";

           numOfTransactions++;

       }
   }
    @Override
    public String toString()
        {
          return " Name: " + customerName + " Balance:"+ balance + " Date:"+ dateCreated;
        }

}

Explanation / Answer

public class SavingAccount extends BankAccount
{

// create a interest field with default value 1%

public double interest = 1.0;
public double balance;
public String name;
public int free_withdraw_Transaction = 3;
public int withdraw_Transactions;
public double penaltyInterest = 2.0;
public String accountType;
public int numOfTransactions;
public int transactions[];
public String transactionsSummary[];

SavingAccount(String name, double balance, int dateCreated)
{
super(name, balance);
this.accountType = "saving";
}
@Override
public double getProjectAmount()
{
return projectAmount;
}
  
public double getBalance()
{
return balance;
}

public void setBalance(double val)
{
balance = balance + val;
}
/**
* @param amount
*/

public double projectAmount(double amount)
{
double newBalance = balance * amount;
return newBalance;
}
// conditional withdraw
//

@Override
public void withdraw(double amount)
{
if (amount <= 0)
{

System.out.println("Amount should be positive");

}
else
{
if (getBalance() <= 0)
{

System.out.println("Balance should be positive");

}
else
{
withdraw_Transactions++;   
   double newBalance = balance - amount;
balance = newBalance;
if (withdraw_Transactions > free_withdraw_Transaction)
{
newBalance = 0.0;
newBalance = (balance * penaltyInterest/100 )/12;
   balance = newBalance;
}

}
}
  
}
@Override
public void deposit(double amount)
{

if (amount <= 0)
{

System.out.println("Amount to be depsited should be positive");

}
else
{

//new balance includes interest

balance = balance + amount + ((amount * interest) / 100) / 12;

transactions[numOfTransactions] = amount;

transactionsSummary[numOfTransactions] = "$"

+ Double.toString(amount) + "was deposited.";

numOfTransactions++;

}
}
@Override
public String toString()
{
return " Name: " + customerName + " Balance:"+ balance + " Date:"+ dateCreated;
}

}

Note:I declared all the variables as global.If you have any errors with this code please let me know

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