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

this needs to be in Java... SavingAccount class -logic addBankAccount( ) SavingA

ID: 3724221 • Letter: T

Question

this needs to be in Java...

SavingAccount class -logic addBankAccount( )

SavingAccount Class data members:

-->private double minBalance;

-->private double interestRate;

Method addBankAccount( ):

CALL super.addBankAccount( )

READ valid minBalance from user

READ valid interestRate from user

Class SavingsAccount This class w be inherited from BankAccount and contains the data members for a savings account (ie interestRate double double minimumBalance) Methods o toString): String - returns the data of the account formatted to display o addBankAccount): bool prompts user to enter data for this object from keyboard edits data, and doesn't allow user to continue with bad data o monthlyAccountUpdate) processes the object with monthly update of adding interest (as long as bank balance minBalance, else displays error message ean - IS more than

Explanation / Answer

import java.util.*;

import java.lang.*;

import java.io.*;

class BankAccount

{

BankAccount(){}

boolean addBankAccount( )

{ return true;}

}

class SavingsAccount extends BankAccount

{

SavingsAccount()

{

minBalance = 0.0;

interestRate = 0.0;

}   

private double minBalance;

private double interestRate;   

public boolean addBankAccount( )

{

//CALL

super.addBankAccount( );

//

// READ valid minBalance from user

  

// Scanner scanner = new Scanner(System.in);

do{

System.out.println("Please enter minimum balance="); // print n

Scanner scanner = new Scanner(System.in);

if(scanner.hasNextDouble())

{

minBalance = scanner.nextDouble(); // read an integer from input stream.

}

else

{

System.out.println("Incorrect value entered!!");

}

}while(minBalance < 0);

  

do{

System.out.println("Please enter interest rate="); // print n

Scanner scanner = new Scanner(System.in);

if(scanner.hasNextDouble())

{

interestRate = scanner.nextDouble(); // read an integer from input stream.

}

else

{

System.out.println("Incorrect value entered!!");

}

}while(interestRate < 0);

  

System.out.println("minimumBalance entered is:" + minBalance);

System.out.println("interestRate entered is:" + interestRate);   

return true;

}

}

/* Name of the class has to be "Main" only if the class is public. */

class Test

{

Test(){}

public static void main (String[] args) throws java.lang.Exception

{

// your code goes here

SavingsAccount sAccount = new SavingsAccount();

sAccount.addBankAccount();

}

}