Hello,
i am creating a class called BankAccount and kind of stuck on a park. Question is :: I am stuck figuring out the savings account part...been at it for hours and no luck. Can any one help or guide me to finish how to do this...Ty much
Create a class called BankAccount in
Java to hold
-Balance
-Number of deposits this month.
-Number of withdrawals.
-Annual Interest rate.
-Monthly charges.
The class should have following methods.
-Constructor (should accept arguments for balance and annual interest rate)
-deposit
-withdraw
-calcInterest(Formulas are Monthly Interest Rate=Annual Interest Rate/12 ,Monthly Interest = Balance * Monthly Interest Rate , Balance = Balance + Monthly Interest)
-monthlyProcess.(method that subtracts monthly service charge from balance,calls calcInterest method and sets the variable that hols number of withdrawals,number of deposits & monthly service charges to 0.
Next,design a SavingsAccount class that extends the BankAccount class. This account should have a status field which represents an active or inactive account.If the balance of saving account falls below $25 account becomes inactive.(No withdrawals allowed until balance is above $25 at which the account becomes active when balance is above $25)
Savings Account should have following methods.
-withdraw (A method that determines whether account is active or inactive.No withdrawal allowed if account is inactive.A withdrawal is then made by calling the superclass version of the method)
-deposit ( Method which checks account is active or inactive..If balance greater than $25 account becomes active.A deposit is then made by calling superclass version of method)
-monthlyProcess before the superclass method is called,, this method checks the number of withdrawals . if the no of withdrawals for the month is greater than 4,a service charge of 1$ for each withdrawal above 4 is added to superclass field that holds the monthly service charges.(don,t forget to check the account balance after the service charge is taken . If the account falss below $25 , the account becomes inactive))
Here is what i have for code so far. Help would be really appreciated!
import java.util.Scanner;
public class BankAccount
{
public static void main(
String[] args){
System.out.println("Welcome to the bank! What do you want to do?");
}
public double balance = 0.0;
public int deposits = 0;
public double withDrawals = 0;
public double annualInterestRate = 0;
public double serviceCharge = 1;
// The constructor to hold balance and Annual Interest Rate
public double accountBalance(double bal, double intRate)
{
balance = bal;
annualInterestRate = intRate;
return balance;
}
public void deposit(double amount)
{
balance +=amount;
deposits++;
}
public void withDrawal(double amount)
{
balance -= amount;
withDrawals++;
}
private void calcInterest()
{
double monthlyInterestRate;
double monthlyInterest;
monthlyInterestRate = (annualInterestRate / 12);
monthlyInterest = balance * monthlyInterestRate;
balance = balance + monthlyInterest;
}
protected void monthlyProcess()
{
balance -= serviceCharge;
calcInterest();
withDrawals = 0;
deposits = 0;
serviceCharge = 0;
}
public double getBalance()
{
return balance;
}
}
And then the SavingAccount
public class SavingsAccount extends BankAccount
{
public SavingsAccount(double balance, double annualInterestRate)
{
super();
}
public void withDrawal(double amount)
{
if(balance >= 25)
super.withDrawal(amount);
else
System.out.println("Your account is inactive. Your balance needs to be over $25." );
}
public void deposit(double amount)
{
if(balance >= 25)
super.deposit(amount);
else
System.out.println("Your account is inactive. Your balance needs to be over $25." );
}
protected void monthlyProcess()
{
if(withDrawals > 4)
serviceCharge++;
else;
}
}
Thanks